Codeforces Round 373 (Div. 2)
B
Anatoly and Cockroaches
Codeforces
1400
原题
← AC →
翻译中…

Anatoly lives in the university dorm as many other students do. As you know, cockroaches are also living there together with students. Cockroaches might be of two colors: black and red. There are $*n*$ cockroaches living in Anatoly's room.

翻译中…

Anatoly just made all his cockroaches to form a single line. As he is a perfectionist, he would like the colors of cockroaches in the line to alternate. He has a can of black paint and a can of red paint. In one turn he can either swap any two cockroaches, or take any single cockroach and change it's color.

翻译中…

Help Anatoly find out the minimum number of turns he needs to make the colors of cockroaches in the line alternate.

翻译中…

Input

翻译中…

The first line of the input contains a single integer $*n*$ ($1 ≤ *n* ≤ 100 000$) — the number of cockroaches.

翻译中…

The second line contains a string of length $*n*$, consisting of characters 'b' and 'r' that denote black cockroach and red cockroach respectively.

翻译中…

Output

翻译中…

Print one integer — the minimum number of moves Anatoly has to perform in order to make the colors of cockroaches in the line to alternate.

翻译中…

Note

翻译中…

In the first sample, Anatoly has to swap third and fourth cockroaches. He needs $1$ turn to do this.

翻译中…

In the second sample, the optimum answer is to paint the second and the fourth cockroaches red. This requires $2$ turns.

翻译中…

In the third sample, the colors of cockroaches in the line are alternating already, thus the answer is $0$.

翻译中…

样例

Input #1
5
rbbrr
Output #1
1
InputCopy OutputCopy
Input #2
5
bbbbb
Output #2
2
InputCopy OutputCopy
Input #3
3
rbr
Output #3
0
InputCopy OutputCopy
题目信息
题号
719B
时间限制
1 s
内存限制
256 MB
标签
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。