Joe recently flunked the CCC (Canadian Computing Competition) and has decided to switch from programming to colouring instead.
In order for a chance to qualify for the prestigious Canadian Colouring Olympiad (CCO), he needs to be able to be able to colour a "good" stripe pattern, which consists of a row of colours that alternate between colour and colour . Examples of good stripe patterns include and but not .
After realizing that he just painted a bad stripe pattern, Joe plans to use his magic paintbrush, which, in a single stroke can change the colour of a single position on his pattern from either colour to colour or vice versa. Given Joe's current stripe pattern as a string of s and s, determine the minimum number of magic brush strokes Joe needs to make his stripe pattern "good".
Input Specification
The first line contains an integer , the length of his pattern.
The second line contains a string of characters, each consisting of either or .
Subtask 1 [5%]
The original pattern will only consist of colour .
Subtask 2 [10%]
Subtask 3 [85%]
No additional constraints
Output Specification
Output one integer: the minimum number of magic brush strokes needed to turn is pattern into a "good" stripe pattern.
Sample Input
5
01011
Sample Output
1
Explanation for Sample Case
Joe can use his magic paintbrush to turn the last stripe to colour , making the pattern , which is a "good" stripe pattern, taking a total of 1 magic brush stroke.
Comments