#P1092. Prefixes(前缀)
Prefixes(前缀)
说明
HXY_error got a string s of even(偶数) length n, which consists only of lowercase letters 'a' and 'b'.
He wants to change his string so that every its prefix of even length has an equal amount of letters 'a' and 'b'. To achieve that, HXY_error can do that: choose some position in his string and replace the letter on this position with the other letter ( replace 'a' with 'b' or replace 'b' with 'a').
For example, for the string s="abba" there are two prefixes of the even length. The first is s[1…2]="ab" and the second s[1…4]="abba". Both of them have the same number of 'a' and 'b'.So the number of operations is zero.
Your task is to calculate the minimum number of operations HXY_error has to perform with the string s to chagne it so that every its prefix of even length has an equal amount of letters 'a' and 'b'.
PS:这题其实很简单,别被英文题面吓到了。
输入格式
The first line of the input contains one even integer n (2 <= n <= 1000) — the length of string s.
The second line of the input contains the string s of length n, which consists only of lowercase Latin letters 'a' and 'b'.
输出格式
In a line print the minimum number of operations HXY_error has to perform with the string s to modify it so that every its prefix of even length has an equal amount of letters 'a' and 'b'.
样例
4
bbbb
2
样例
6
ababab
0
样例
2
aa
1
提示
In the first example HXY_error has to perform two operations. For example, he can replace the first 'b' with 'a' and the last 'b' with 'a'.
In the second example HXY_error doesn't need to do anything because each prefix of an even length of the initial string already contains an equal amount of letters 'a' and 'b'.