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.


-----Examples-----
Input
5
rbbrr

Output
1

Input
5
bbbbb

Output
2

Input
3
rbr

Output
0



-----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.

Difficulty: MEDIUM

Solutions:
n = int(input())
s = input()
red_black = True
swap_red = {'b': 0, 'r': 0}
swap_black = {'b': 0, 'r': 0}
for c in s:
	if red_black is True and c != 'b':
		swap_black['r'] += 1
	elif red_black is False and c != 'r':
		swap_black['b'] += 1
	if red_black is True and c != 'r':
		swap_red['b'] += 1
	elif red_black is False and c != 'b':
		swap_red['r'] += 1
	red_black = True if red_black is False else False
black = swap_black[max(swap_black, key=swap_black.get)] - swap_black[min(swap_black, key=swap_black.get)] + swap_black[min(swap_black, key=swap_black.get)]
red = swap_red[max(swap_red, key=swap_red.get)] - swap_red[min(swap_red, key=swap_red.get)] + swap_red[min(swap_red, key=swap_red.get)]
print(int(min(red, black)))


n = int(input())
series = input()
series2 = 'br' * n
series3 = 'rb' * n
count1a = 0
count1b = 0
count2a = 0
count2b = 0
for x in range(n):
	if series[x] == series2[x]:
		continue
	elif series[x] == 'r':
		count1a = count1a + 1
	elif series[x] == 'b':
		count1b = count1b + 1
for x in range(n):
	if series[x] == series3[x]:
		continue
	elif series[x] == 'r':
		count2a = count2a + 1
	elif series[x] == 'b':
		count2b = count2b + 1
moves1 = min(count1a, count1b) + abs(count1a - count1b)
moves2 = min(count2a, count2b) + abs(count2a - count2b)
print(min(moves1, moves2))


n = int(input())
a = input()
p1 = 0
p2 = 0
for i in range(n):
	if i % 2 and a[i] != 'r':
		p1 += 1
	if not i % 2 and a[i] != 'b':
		p2 += 1
m1 = max(p1, p2)
p1 = 0
p2 = 0
for i in range(n):
	if i % 2 and a[i] != 'b':
		p1 += 1
	if not i % 2 and a[i] != 'r':
		p2 += 1
m2 = max(p1, p2)
print(min(m1, m2))


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
MOD = 1000000007

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
s = input()
odd = [s[i] for i in range(n) if i % 2]
even = [s[i] for i in range(n) if not i % 2]
needs1 = even.count('r')
needs2 = odd.count('b')
ans = min(needs1, needs2) + abs(needs2 - needs1)
needs1 = even.count('b')
needs2 = odd.count('r')
ans = min(ans, min(needs1, needs2) + abs(needs2 - needs1))
print(ans)


def B():
	n = int(input())
	lst = list(input())
	for i in range(len(lst)):
		if lst[i] == 'r':
			lst[i] = 1
		else:
			lst[i] = -1
	rCo = 0
	bCo = 0
	co = 0
	cur = lst[0]
	if n == 1:
		print('0')
		return 0
	for i in range(len(lst)):
		if lst[i] == cur:
			cur *= -1
			continue
		else:
			if lst[i] == 1:
				if bCo != 0:
					bCo -= 1
				else:
					rCo += 1
					co += 1
			elif rCo != 0:
				rCo -= 1
			else:
				bCo += 1
				co += 1
			cur *= -1
	first = co
	rCo = 0
	bCo = 0
	co = 0
	cur = lst[0] * -1
	for i in range(len(lst)):
		if lst[i] == cur:
			cur *= -1
			continue
		else:
			if lst[i] == 1:
				if bCo != 0:
					bCo -= 1
				else:
					rCo += 1
					co += 1
			elif rCo != 0:
				rCo -= 1
			else:
				bCo += 1
				co += 1
			cur *= -1
	print(min(co, first))
	return 0

def __starting_point():
	B()
__starting_point()


n = int(input())
a = list(input())
ans = (float('+inf'), float('+inf'))
x = 0
y = 0
for i in range(n):
	if i & 1 and a[i] != 'r':
		x += 1
	elif not i & 1 and a[i] != 'b':
		y += 1
ans = min(ans, (x, y))
x = 0
y = 0
for i in range(n):
	if not i & 1 and a[i] != 'r':
		x += 1
	elif i & 1 and a[i] != 'b':
		y += 1
ans = min(ans, (x, y))
print(max(ans))


N = int(input())
(This, Ans) = (input(), [])
for i in ['rb', 'br']:
	Should = i * (N // 2) + i[:N % 2]
	WasR = This.count('r')
	NowR = Should.count('r')
	Diff = sum((1 for (i, j) in zip(This, Should) if i != j))
	Ans.append((Diff - abs(WasR - NowR)) // 2 + abs(WasR - NowR))
print(min(Ans))


n = int(input())
s = input()
a = s[::2].count('r')
b = s[1::2].count('b')
c = s[::2].count('b')
d = s[1::2].count('r')
print(min(min(a, b) + abs(a - b), min(c, d) + abs(c - d)))


def main():
	n = int(input())
	s = input()
	rodd = 0
	bodd = 0
	reven = 0
	beven = 0
	for (i, c) in enumerate(s):
		if i % 2 == 1:
			if c == 'r':
				rodd += 1
			else:
				bodd += 1
		elif c == 'r':
			reven += 1
		else:
			beven += 1
	print(min(abs(bodd - reven) + min(bodd, reven), abs(rodd - beven) + min(rodd, beven)))
main()


def solve(arr):
	f = min(arr.count('b'), arr.count('r'))
	return len(arr) - f
n = int(input())
s = input()
accs0 = []
accs1 = []
for i in range(n):
	if i % 2 == 1:
		if s[i] == 'r':
			accs0.append(s[i])
		else:
			accs1.append(s[i])
	elif s[i] != 'r':
		accs0.append(s[i])
	else:
		accs1.append(s[i])
print(min(solve(accs1), solve(accs0)))


n = int(input())
s = input()
(r, b) = (0, 0)
for x in s:
	if x == 'r':
		r += 1
	else:
		b += 1
trr = [x for x in s]
if n:
	krr = trr[:]
	c = 0
	i = 0
	for p in range(0, n, 2):
		if krr[p] == 'b':
			i += 1
	j = 0
	for p in range(1, n, 2):
		if krr[p] == 'r':
			j += 1
	krr = trr[:]
	lrr = [max(i, j)]
	c = 0
	i = 0
	for p in range(0, n, 2):
		if krr[p] == 'r':
			i += 1
	j = 0
	for p in range(1, n, 2):
		if krr[p] == 'b':
			j += 1
	lrr.append(max(i, j))
	print(min(lrr))


n = int(input())
s = input()
k = s
(ans, c, sr, sb) = (0, 0, 0, 0)
black = True
red = False
for i in s:
	if black and i == 'b':
		if sr > 0:
			sr = sr - 1
		else:
			c = c + 1
			sb = sb + 1
	elif red and i == 'r':
		if sb > 0:
			sb = sb - 1
		else:
			c = c + 1
			sr = sr + 1
	(black, red) = (red, black)
black = False
red = True
for i in s:
	if black and i == 'b':
		if sr > 0:
			sr = sr - 1
		else:
			ans = ans + 1
			sb = sb + 1
	elif red and i == 'r':
		if sb > 0:
			sb = sb - 1
		else:
			ans = ans + 1
			sr = sr + 1
	(black, red) = (red, black)
print(min(ans, c))


(cnt_b1, cnt_r1, cnt_b2, cnt_r2) = (0, 0, 0, 0)
num = int(input())
s = input()
for (i, c) in enumerate(s):
	if i % 2 == 0:
		if c == 'r':
			cnt_r1 += 1
		else:
			cnt_b1 += 1
	elif c == 'r':
		cnt_r2 += 1
	else:
		cnt_b2 += 1
print(min(max(cnt_b2, cnt_r1), max(cnt_r2, cnt_b1)))


n = int(input())
val = list(input())
m = n // 2
if n & 1:
	rb = list('rb' * m + 'r')
	br = list('br' * m + 'b')
else:
	rb = list('rb' * m)
	br = list('br' * m)

def solve(text):
	(r, b) = (0, 0)
	for i in range(n):
		if val[i] != text[i]:
			if val[i] == 'r':
				r += 1
			else:
				b += 1
	return max(r, b)
ans = min(solve(rb), solve(br))
print(ans)


n = int(input())
s = input()
(sb, sr) = (0, 0)
for i in range(0, n):
	if i % 2 and s[i] != 'b':
		sb += 1
	if not i % 2 and s[i] != 'r':
		sr += 1
maxx = max(sr, sb)
(sr, sb) = (0, 0)
for i in range(0, n):
	if i % 2 and s[i] != 'r':
		sr += 1
	if not i % 2 and s[i] != 'b':
		sb += 1
maxx1 = max(sr, sb)
print(min(maxx, maxx1))


n = int(input())
s = input()
(a, b, c, d) = (0, 0, 0, 0)
for i in range(n):
	if s[i] == 'r' and i % 2 == 0:
		a = a + 1
	elif s[i] == 'b' and i % 2 == 1:
		b = b + 1
	elif s[i] == 'r' and i % 2 == 1:
		c = c + 1
	elif s[i] == 'b' and i % 2 == 0:
		d = d + 1
print(min(max(a, b), max(c, d)))


n = int(input())
line = input()
(start1, start2, r2b1, r2b2, b2r1, b2r2) = ('r', 'b', 0, 0, 0, 0)
idx = 0
while idx < n:
	b2r1 += start1 == 'r' and line[idx] == 'b'
	r2b1 += start1 == 'b' and line[idx] == 'r'
	b2r2 += start2 == 'r' and line[idx] == 'b'
	r2b2 += start2 == 'b' and line[idx] == 'r'
	start1 = ['r', 'b'][start1 == 'r']
	start2 = ['r', 'b'][start2 == 'r']
	idx += 1
print(min(max(r2b1, b2r1), max(r2b2, b2r2)))


def solve(pole, nxt):
	opposite = {'r': 'b', 'b': 'r'}
	count_not_on_place = {'r': 0, 'b': 0}
	for item in pole:
		if nxt != item:
			count_not_on_place[item] += 1
		nxt = opposite[nxt]
	return max(count_not_on_place.values())
_ = input()
a = input()
print(min(solve(a, 'r'), solve(a, 'b')))


n = input()
text = input()
switcher = -1
lastbad = 0
tries = 10000000
triecount = 0
triecount2 = 0
counter = -1
abad1 = 0
abad2 = 0
for a in text:
	counter += 1
	switcher *= -1
	if a == 'r' and switcher == -1:
		abad1 += 1
	if a == 'b' and switcher == 1:
		abad2 += 1
if abad1 >= abad2:
	triecount = abad1
else:
	triecount = abad2
if triecount < tries:
	tries == triecount
tc1 = triecount
switcher = -1
abad1 = 0
abad2 = 0
for a in text:
	counter += 1
	switcher *= -1
	if a == 'b' and switcher == -1:
		abad1 += 1
	if a == 'r' and switcher == 1:
		abad2 += 1
if abad1 >= abad2:
	triecount2 = abad1
else:
	triecount2 = abad2
tc1 = triecount
tc2 = triecount2
if tc1 <= tc2:
	print(tc1)
else:
	print(tc2)


def main(n, s):
	a = 0
	b = 0
	c = 0
	d = 0
	for i in range(n):
		if s[i] == 'r' and i % 2 == 0:
			a += 1
		if s[i] == 'b' and i % 2 == 1:
			b += 1
		if s[i] == 'b' and i % 2 == 0:
			c += 1
		if s[i] == 'r' and i % 2 == 1:
			d += 1
	return min(max(a, b), max(c, d))
print(main(int(input()), list(input())))


n = int(input())
s = input()
r = 0
r1 = 0
b = 0
b1 = 0
for i in range(n):
	if i % 2 == 0:
		if s[i] != 'r':
			r = r + 1
		else:
			b1 = b1 + 1
	elif s[i] != 'b':
		b = b + 1
	else:
		r1 = r1 + 1
print(min(max(r, b), max(r1, b1)))


import math
n = int(input())
insects = input()
resr1 = 0
resb1 = 0
for i in range(n):
	if i % 2 == 0 and insects[i] == 'r':
		resr1 += 1
	elif i % 2 == 1 and insects[i] == 'b':
		resb1 += 1
res1 = min(resr1, resb1) + abs(resr1 - resb1)
resr2 = 0
resb2 = 0
for i in range(n):
	if i % 2 == 0 and insects[i] == 'b':
		resb2 += 1
	elif i % 2 == 1 and insects[i] == 'r':
		resr2 += 1
res2 = min(resr2, resb2) + abs(resr2 - resb2)
print(min(res1, res2))


def check(ch):
	other = 'r' if ch == 'b' else 'b'
	wrong_ch = 0
	wrong_ot = 0
	for i in range(n):
		if i % 2 != 0 and st[i] == ch:
			wrong_ch += 1
		if i % 2 == 0 and st[i] == other:
			wrong_ot += 1
	return max(wrong_ot, wrong_ch)

def func():
	ans1 = check('r')
	ans2 = check('b')
	print(min(ans1, ans2))
n = int(input())
st = list(input())
func()


n = int(input())
s = input()
if n % 2 == 0:
	a = 'rb' * (n // 2)
	b = 'br' * (n // 2)
else:
	a = 'rb' * ((n - 1) // 2) + 'r'
	b = 'br' * ((n - 1) // 2) + 'b'
rr = 0
bb = 0
res = []
for i in range(n):
	if a[i] == 'r' and s[i] == 'b':
		rr += 1
		continue
	elif a[i] == 'b' and s[i] == 'r':
		bb += 1
		continue
res.append(max(rr, bb))
rr = 0
bb = 0
for i in range(n):
	if b[i] == 'r' and s[i] == 'b':
		rr += 1
		continue
	elif b[i] == 'b' and s[i] == 'r':
		bb += 1
		continue
res.append(max(rr, bb))
print(min(res))


def build_line(first, n):
	elems = ['r', 'b']
	result = []
	for _ in range(n):
		result.append(elems[first % 2])
		first += 1
	return ''.join(result)

def compare_lines(expected, actual):
	red_unordered = 0
	black_unordered = 0
	for i in range(len(actual)):
		if expected[i] != actual[i]:
			if actual[i] == 'r':
				red_unordered += 1
			else:
				black_unordered += 1
	return max(red_unordered, black_unordered)
n = int(input())
cockroaches = input()
red_res = compare_lines(build_line(0, n), cockroaches)
black_res = compare_lines(build_line(1, n), cockroaches)
print(min(red_res, black_res))


n = int(input())
s = input()
s1 = ''
s2 = ''
for i in range(n):
	if i % 2 == 0:
		s1 += 'r'
		s2 += 'b'
	else:
		s1 += 'b'
		s2 += 'r'
red = 0
blk = 0
for i in range(n):
	if s[i] != s1[i] and s[i] == 'b':
		blk += 1
	elif s[i] != s1[i]:
		red += 1
ans = max(red, blk)
red = 0
blk = 0
for i in range(n):
	if s[i] != s2[i] and s[i] == 'b':
		blk += 1
	elif s[i] != s2[i]:
		red += 1
ans = min(ans, max(red, blk))
print(ans)


n = int(input())
s = input()
c = 1
c1r = 0
c1b = 0
c2r = 0
c2b = 0
for x in range(0, len(s)):
	if c == 1:
		if s[x] == 'b':
			c1r = c1r + 1
		else:
			c2b = c2b + 1
		c = 2
	else:
		if s[x] == 'r':
			c1b = c1b + 1
		else:
			c2r = c2r + 1
		c = 1
print(min(max(c1r, c1b), max(c2r, c2b)))


n = int(input())
l = list(input())
final1 = []
final2 = []
for i in range(len(l)):
	if i % 2 == 0:
		final1.append('r')
		final2.append('b')
	else:
		final1.append('b')
		final2.append('r')
nr = 0
nb = 0
for i in range(n):
	if final1[i] == 'r' and final1[i] != l[i]:
		nr += 1
	elif final1[i] == 'b' and final1[i] != l[i]:
		nb += 1
maxx1 = max(nr, nb)
nr = 0
nb = 0
for i in range(n):
	if final2[i] == 'r' and final2[i] != l[i]:
		nr += 1
	elif final2[i] == 'b' and final2[i] != l[i]:
		nb += 1
maxx2 = max(nr, nb)
print(min(maxx1, maxx2))


n = int(input())
s = input()
m = n // 2
rem = n % 2
first = 'rb' * m + 'r' * rem
second = 'br' * m + 'b' * rem
(r1, b1, r2, b2) = (0, 0, 0, 0)
for i in range(n):
	if s[i] != first[i]:
		if s[i] == 'b':
			b1 += 1
		else:
			r1 += 1
	if s[i] != second[i]:
		if s[i] == 'b':
			b2 += 1
		else:
			r2 += 1
print(min(max(r1, b1), max(r2, b2)))


n = int(input())
s = input()
b = 0
r = 0
p = s[0]
for i in range(1, n):
	if s[i] == p:
		if s[i] == 'b':
			b += 1
			p = 'r'
		else:
			r += 1
			p = 'b'
	else:
		p = s[i]
o = max(b, r)
b = 0
r = 0
if s[0] == 'b':
	p = 'r'
	b += 1
else:
	p = 'b'
	r += 1
for i in range(1, n):
	if s[i] == p:
		if s[i] == 'b':
			b += 1
			p = 'r'
		else:
			r += 1
			p = 'b'
	else:
		p = s[i]
print(min(o, max(b, r)))


a = input()

def a0o1(character):
	if character == 'r':
		return 0
	if character == 'b':
		return 1

def isPar(par):
	return par == 0
b = list(map(a0o1, input()))
par = 0
a1_miss_0 = 0
a1_miss_1 = 0
a2_miss_0 = 0
a2_miss_1 = 0
for x in b:
	a1_miss_0 += x == 0 and isPar(par)
	a1_miss_1 += x == 1 and (not isPar(par))
	a2_miss_0 += x == 0 and (not isPar(par))
	a2_miss_1 += x == 1 and isPar(par)
	par = (par + 1) % 2
a1_changes = abs(a1_miss_0 - a1_miss_1)
a1_swaps = max(a1_miss_0, a1_miss_1) - a1_changes
a_1 = a1_changes + a1_swaps
a2_changes = abs(a2_miss_0 - a2_miss_1)
a2_swaps = max(a2_miss_0, a2_miss_1) - a2_changes
a_2 = a2_changes + a2_swaps
print(min(a_1, a_2))


n = int(input())
s = list(input())
order = 'rb'
data0 = sum(map(lambda x, y: order.index(x) == 0 and y % 2 == 0, s, range(n)))
data1 = sum(map(lambda x, y: order.index(x) == 1 and y % 2 == 1, s, range(n)))
count1 = max(data0, data1)
order = 'br'
data0 = sum(map(lambda x, y: order.index(x) == 0 and y % 2 == 0, s, range(n)))
data1 = sum(map(lambda x, y: order.index(x) == 1 and y % 2 == 1, s, range(n)))
count2 = max(data0, data1)
print(min(count1, count2))


n = int(input())
line = input()
black0 = black1 = red0 = red1 = 0
for (i, cock) in enumerate(line):
	if i % 2 == 0 and cock == 'r':
		red0 += 1
	elif i % 2 == 1 and cock == 'r':
		red1 += 1
	elif i % 2 == 0 and cock == 'b':
		black0 += 1
	elif i % 2 == 1 and cock == 'b':
		black1 += 1
ans = min(max(red0, black1), max(red1, black0))
print(ans)


import sys
input = sys.stdin.readline
from collections import defaultdict
opp = {'r': 'b', 'b': 'r'}

def func(n, a, want, d):
	curr = defaultdict(int)
	ans = 0
	for i in range(n):
		if a[i] != want[i]:
			if curr[d[a[i]]] > 0:
				curr[d[a[i]]] -= 1
			else:
				curr[a[i]] += 1
				ans += 1
	return ans
n = int(input())
a = input()
want1 = 'r'
want2 = 'b'
for i in range(1, n):
	want1 += opp[want1[i - 1]]
	want2 += opp[want2[i - 1]]
ans = func(n, a, want1, opp)
ans = min(ans, func(n, a, want2, opp))
print(ans)


from math import *
n = int(input())
A = input()
r = 0
b = 0
if n % 2 == 0:
	a1 = 'br' * (n // 2)
	a2 = 'rb' * (n // 2)
else:
	a1 = 'b' + 'rb' * ((n - 1) // 2)
	a2 = 'r' + 'br' * ((n - 1) // 2)
ans1 = 0
ans2 = 0
for j in range(n):
	if A[j] == 'b':
		b += 1
	else:
		r += 1
	if A[j] != a1[j]:
		ans1 += 1
	if A[j] != a2[j]:
		ans2 += 1
if ans1 == 0 or ans2 == 0:
	print(0)
else:
	r1 = n // 2
	b1 = n % 2 + n // 2
	b2 = n // 2
	r2 = n % 2 + n // 2
	min1 = 0
	min2 = 0
	if r1 > r:
		min1 += r1 - r
	if b1 > b:
		min1 += b1 - b
	if r2 > r:
		min2 += r2 - r
	if b2 > b:
		min2 += b2 - b
	print(min(ceil(min1 + (ans1 - min1) // 2), ceil(min2 + (ans2 - min2) // 2)))


n = int(input())
s = input()
cwred = 0
cwblack = 0
res = 0
for i in range(n):
	if i % 2 == 0 and s[i] == 'b':
		cwblack += 1
	if i % 2 == 1 and s[i] == 'r':
		cwred += 1
res = min(cwblack, cwred) + abs(cwblack - cwred)
cwred = 0
cwblack = 0
for i in range(n):
	if i % 2 == 1 and s[i] == 'b':
		cwblack += 1
	if i % 2 == 0 and s[i] == 'r':
		cwred += 1
if res > min(cwblack, cwred) + abs(cwblack - cwred):
	res = min(cwblack, cwred) + abs(cwblack - cwred)
print(res)


a = int(input())
b = input()
s1 = 0
s2 = 0
ss1 = 0
ss2 = 0
for i in range(0, a):
	if b[i] == 'r' and i % 2 == 1:
		s1 += 1
	elif b[i] == 'r':
		ss1 += 1
	elif b[i] == 'b' and i % 2 == 0:
		s2 += 1
	else:
		ss2 += 1
s = min(max(s1, s2), max(ss1, ss2))
print(s)


from sys import stdin, stdout
n = int(stdin.readline())
colours = stdin.readline().strip()
(cntf, cnts) = (0, 0)
label = colours[0]
for i in range(n):
	if i % 2 and label == colours[i]:
		cntf += 1
	elif not i % 2 and label != colours[i]:
		cnts += 1
ans = max(cntf, cnts)
(cntf, cnts) = (0, 0)
for i in range(n):
	if i % 2 and label != colours[i]:
		cntf += 1
	elif not i % 2 and label == colours[i]:
		cnts += 1
ans = min(ans, max(cntf, cnts))
stdout.write(str(ans))


a = int(input())
mas = input()
count1 = 0
count2 = 0
count3 = 0
count4 = 0
for i in range(0, a, 2):
	if mas[i] == 'b':
		count1 += 1
for i in range(1, a, 2):
	if mas[i] == 'r':
		count2 += 1
for i in range(1, a, 2):
	if mas[i] == 'b':
		count3 += 1
for i in range(0, a, 2):
	if mas[i] == 'r':
		count4 += 1
print(min(max(count2, count1), max(count4, count3)))


def solve():
	n = int(input())
	s = input()
	ans1b = 0
	ans1r = 0
	ans2b = 0
	ans2r = 0
	for (i, c) in enumerate(s):
		if i % 2 == 0:
			if c == 'b':
				ans1r += 1
			else:
				ans2b += 1
		elif c == 'r':
			ans1b += 1
		else:
			ans2r += 1
	print(min(max(ans1b, ans1r), max(ans2b, ans2r)))

def main():
	solve()
main()


input()
S = 4 * [0]
e = 0
for c in input():
	S[e | ('r' != c) << 1] += 1
	e = not e
print(min(max(S[0], S[3]), max(S[1], S[2])))


N = int(input())
S = input()
not_r = 0
not_b = 0
for (i, s) in enumerate(S):
	if i % 2 == 0:
		if s != 'r':
			not_r += 1
	elif s != 'b':
		not_b += 1
ans = max(not_r, not_b)
not_r = 0
not_b = 0
for (i, s) in enumerate(S):
	if i % 2 == 0:
		if s != 'b':
			not_b += 1
	elif s != 'r':
		not_r += 1
ans = min(ans, max(not_r, not_b))
print(ans)


n = int(input())
colors = input()
r1 = 0
b1 = 0
r2 = 0
b2 = 0
for i in range(n):
	if i % 2 == 1:
		if colors[i] == 'b':
			r1 += 1
		else:
			b2 += 1
	elif colors[i] == 'r':
		b1 += 1
	else:
		r2 += 1
maximum = min(max(r1, b1), max(r2, b2))
print(maximum)


n = int(input())
w = input().strip()
red_1 = 0
red_2 = 0
bck_1 = 0
bck_2 = 0
for i in range(len(w)):
	if w[i] == 'r':
		if i % 2:
			red_2 += 1
		else:
			red_1 += 1
	if w[i] == 'b':
		if i % 2:
			bck_2 += 1
		else:
			bck_1 += 1
print(min(max(red_2, bck_1), max(bck_2, red_1)))


def calc(pat):
	nR = nB = 0
	for i in range(n):
		if s[i] != pat[i]:
			if s[i] == 'b':
				nB += 1
			else:
				nR += 1
	return max(nR, nB)
n = int(input())
s = list(input())
r = 'rb' * (n // 2) + 'r' * (n & 1)
b = 'br' * (n // 2) + 'b' * (n & 1)
print(min(calc(r), calc(b)))


import sys

def read():
	return sys.stdin.readline().strip()

def printf(a, sep=' ', end='\n'):
	sys.stdout.write(sep.join(map(str, a)) + end)

def readf():
	return [int(i) for i in read().split()]

def dist(s, t, n):
	k = 0
	r = 0
	b = 0
	for i in range(n):
		if s[i] != t[i]:
			if s[i] == 'b':
				b += 1
			else:
				r += 1
			k += 1
	q = min(b, r)
	k -= q * 2
	return q + k

def main():
	n = int(read())
	t = [str(i) for i in read()]
	a = ['r' if i % 2 == 0 else 'b' for i in range(n)]
	b = ['r' if i % 2 == 1 else 'b' for i in range(n)]
	printf([min(dist(a, t, n), dist(b, t, n))])
main()


def dist(s, choice):
	r_diff = 0
	b_diff = 0
	for i in range(len(s)):
		if choice[i] != s[i]:
			if s[i] == 'r':
				r_diff += 1
			else:
				b_diff += 1
	min_diff = min(r_diff, b_diff)
	return min_diff + (r_diff - min_diff) + (b_diff - min_diff)
n = int(input())
a = list(input())
choice_one = []
choice_two = []
for i in range(len(a)):
	if i % 2 == 0:
		choice_one.append('r')
		choice_two.append('b')
	else:
		choice_one.append('b')
		choice_two.append('r')
print(min(dist(a, choice_one), dist(a, choice_two)))


n = int(input())
opt = input()
(ans1, ans2, ans3, ans4) = (0, 0, 0, 0)
for i in range(len(opt)):
	if i % 2:
		if opt[i] == 'r':
			ans1 += 1
		else:
			ans2 += 1
	elif opt[i] == 'r':
		ans3 += 1
	else:
		ans4 += 1
ans = min(max(ans1, ans4), max(ans2, ans3))
print(ans)


n = int(input())
s1 = input()
s2a = ''
da = 0
ar = 0
ab = 0
s2b = ''
db = 0
br = 0
bb = 0
pairs = int(n // 2)
carry = n % 2
for _ in range(pairs):
	s2a += 'rb'
	s2b += 'br'
if carry:
	s2a += 'r'
	s2b += 'b'
if s1 == s2a or s1 == s2b:
	print(0)
	return
for i in range(n):
	if not s1[i] == s2a[i]:
		da += 1
		if s1[i] == 'r':
			ar += 1
		else:
			ab += 1
	if not s1[i] == s2b[i]:
		db += 1
		if s1[i] == 'r':
			br += 1
		else:
			bb += 1
da -= min(ar, ab)
db -= min(br, bb)
print(min(da, db))


def solve(s, p):
	c = [0, 0]
	m = 0
	for i in range(len(s)):
		if s[i] != p[i]:
			if s[i] == 'b':
				if c[1] > 0:
					c[1] -= 1
				else:
					c[0] += 1
					m += 1
			elif c[0] > 0:
				c[0] -= 1
			else:
				c[1] += 1
				m += 1
	return m
n = int(input())
s = input()
p1 = 'rb' * (n // 2 + 1)
p2 = 'br' * (n // 2 + 1)
print(min(solve(s, p1), solve(s, p2)))


n = input()
n = int(n)
adjust = input()
xr = 0
xb = 0
yr = 0
yb = 0
for i in range(0, len(adjust)):
	if i % 2 == 0:
		if adjust[i] == 'r':
			xr += 1
		else:
			xb += 1
	elif adjust[i] == 'r':
		yr += 1
	else:
		yb += 1
sum = min(max(xr, yb), max(yr, xb))
print(sum)


n = int(input())
s = input()
e = 'rb' * (n // 2) + 'r' * (n % 2)
w = 'br' * (n // 2) + 'b' * (n % 2)
lenn = len(s)
(f, r, b, rr, bb) = (0, 0, 0, 0, 0)
for i in range(lenn):
	if s[i] != e[i]:
		if s[i] == 'r':
			r += 1
		else:
			b += 1
	if s[i] != w[i]:
		if s[i] == 'r':
			rr += 1
		else:
			bb += 1
f = min(max(r, b), max(rr, bb))
print(f)


n = int(input())
string = input()

def solve(s, l1, l2):
	answer = 0
	counter1 = 0
	counter2 = 0
	for (n, i) in enumerate(s):
		if n % 2 == 0:
			if i != l1:
				if counter1 > 0:
					counter1 -= 1
				else:
					counter2 += 1
					answer += 1
		elif i != l2:
			if counter2 > 0:
				counter2 -= 1
			else:
				counter1 += 1
				answer += 1
	return answer
print(min(solve(string, 'r', 'b'), solve(string, 'b', 'r')))


from sys import stdin
n = int(input())
ss = input()
fx = fy = sx = sy = 0
for i in range(len(ss)):
	if i % 2 == 0:
		if ss[i] == 'b':
			sx += 1
		if ss[i] == 'r':
			fy += 1
	else:
		if ss[i] == 'b':
			fx += 1
		if ss[i] == 'r':
			sy += 1
print(min(max(fx, fy), max(sx, sy)))


n = int(input())
s = input()
black = ''
red = ''
for i in range(n):
	if i % 2 == 0:
		black += 'b'
		red += 'r'
	else:
		black += 'r'
		red += 'b'
black_b = 0
black_r = 0
red_b = 0
red_r = 0
for i in range(n):
	if s[i] != black[i]:
		if s[i] == 'b':
			black_r += 1
		else:
			black_b += 1
	if s[i] != red[i]:
		if s[i] == 'b':
			red_r += 1
		else:
			red_b += 1
ans1 = max(red_b, red_r)
ans2 = max(black_b, black_r)
print(min(ans1, ans2))


n = int(input())
cockroaches = input()

def get_color_range(start_color):
	color = start_color
	while True:
		if color == 'b':
			color = 'r'
		else:
			color = 'b'
		yield color
color_range1 = get_color_range('r')
color_range2 = get_color_range('b')
r1 = r2 = b1 = b2 = 0
for color in cockroaches:
	if color != next(color_range1):
		if color == 'r':
			r1 += 1
		else:
			b1 += 1
	if color != next(color_range2):
		if color == 'r':
			r2 += 1
		else:
			b2 += 1
variant1 = min(r1, b1) + abs(r1 - b1)
variant2 = min(r2, b2) + abs(r2 - b2)
print(min(variant1, variant2))


n = int(input())
s = input()
(xb, yb, xr, yr) = (0, 0, 0, 0)
for i in range(n):
	if i % 2 == 0 and s[i] == 'b':
		xr += 1
	elif i % 2 == 1 and s[i] == 'r':
		yr += 1
for i in range(n):
	if i % 2 == 0 and s[i] == 'r':
		yb += 1
	elif i % 2 == 1 and s[i] == 'b':
		xb += 1
print(min(max(yb, xb), max(xr, yr)))


n = int(input())
s = input()
r1 = b1 = r2 = b2 = 0
for i in range(len(s)):
	if i % 2:
		if s[i] == 'r':
			r1 += 1
		else:
			r2 += 1
	elif s[i] == 'b':
		b1 += 1
	else:
		b2 += 1
print(min(abs(r1 - b1) + min(r1, b1), abs(r2 - b2) + min(r2, b2)))


n = int(input())
s = input()
(p1, p2) = (0, 0)
for i in range(n):
	if i % 2 and s[i] != 'r':
		p1 += 1
	if not i % 2 and s[i] != 'b':
		p2 += 1
r1 = max(p1, p2)
(p1, p2) = (0, 0)
for i in range(n):
	if i % 2 and s[i] != 'b':
		p1 += 1
	if not i % 2 and s[i] != 'r':
		p2 += 1
r2 = max(p1, p2)
print(min(r1, r2))


n = int(input())
c = input()
(e1, o1, e2, o2) = (0, 0, 0, 0)
for x in range(0, n, 2):
	if c[x] != 'r':
		e1 += 1
for y in range(1, n, 2):
	if c[y] != 'b':
		o1 += 1
for x in range(0, n, 2):
	if c[x] != 'b':
		e2 += 1
for y in range(1, n, 2):
	if c[y] != 'r':
		o2 += 1
print(min(max(e1, o1), max(e2, o2)))


n = int(input())
roaches = input()
b_roaches_total = 0
b_roaches_even = 0
r_roaches_total = 0
r_roaches_even = 0
for i in range(len(roaches)):
	if roaches[i] == 'b':
		b_roaches_total += 1
		if i % 2 == 0:
			b_roaches_even += 1
	else:
		r_roaches_total += 1
		if i % 2 == 0:
			r_roaches_even += 1
b_roaches_odd = b_roaches_total - b_roaches_even
r_roaches_odd = r_roaches_total - r_roaches_even
if b_roaches_odd >= b_roaches_even and r_roaches_even >= r_roaches_odd:
	print(max(b_roaches_even, r_roaches_odd))
else:
	print(max(b_roaches_odd, r_roaches_even))


T = 1
for t in range(T):
	n = int(input())
	s = input()
	wrong_red = 0
	wrong_black = 0
	for i in range(n):
		if i % 2 == 0 and s[i] == 'r':
			wrong_red += 1
		if i % 2 == 1 and s[i] == 'b':
			wrong_black += 1
	if wrong_black < wrong_red:
		total_moves = wrong_black + (wrong_red - wrong_black)
	else:
		total_moves = wrong_red + (wrong_black - wrong_red)
	wrong_red = 0
	wrong_black = 0
	for i in range(n):
		if i % 2 == 1 and s[i] == 'r':
			wrong_red += 1
		if i % 2 == 0 and s[i] == 'b':
			wrong_black += 1
	if wrong_black < wrong_red:
		total_moves = min(total_moves, wrong_black + (wrong_red - wrong_black))
	else:
		total_moves = min(total_moves, wrong_red + (wrong_black - wrong_red))
	print(total_moves)


n = int(input())
stroy = input()
order = stroy[0]
wrong_r1 = 0
wrong_b1 = 0
wrong_b2 = 0
wrong_r2 = 0
for i in range(n):
	if i % 2 == 0:
		if stroy[i] == 'b':
			wrong_b1 += 1
		else:
			wrong_r1 += 1
	elif stroy[i] == 'b':
		wrong_b2 += 1
	else:
		wrong_r2 += 1
print(min(max(wrong_b1, wrong_r2), max(wrong_r1, wrong_b2)))


n = int(input())
ch = input()
(r1, r2, b1, b2) = (0, 0, 0, 0)
for i in range(n):
	if i % 2 == 0:
		if ch[i] != 'r':
			r1 += 1
		if ch[i] != 'b':
			b2 += 1
	if i % 2 != 0:
		if ch[i] == 'r':
			b1 += 1
		if ch[i] == 'b':
			r2 += 1
print(min(max(r1, b1), max(r2, b2)))


n = int(input())
s = input()
if s.count('b') == n or s.count('r') == n:
	print(n // 2)
else:
	s_r_count_r = 0
	s_r_count_b = 0
	s_b_count_r = 0
	s_b_count_b = 0
	for i in range(n):
		if i % 2 == 0 and s[i] == 'r' or (i % 2 == 1 and s[i] == 'b'):
			if i % 2 == 0:
				s_b_count_b += 1
			else:
				s_b_count_r += 1
		elif i % 2 == 0:
			s_r_count_r += 1
		else:
			s_r_count_b += 1
	print(min(max(s_r_count_r, s_r_count_b), max(s_b_count_r, s_b_count_b)))


a = int(input())
b = input()
z1 = 0
x1 = 0
for i in range(a):
	if i % 2 == 1:
		if b[i] == 'r':
			z1 += 1
	elif i % 2 == 0:
		if b[i] == 'b':
			x1 += 1
y1 = max(z1, x1)
z2 = 0
x2 = 0
for i in range(a):
	if i % 2 == 1:
		if b[i] == 'b':
			z2 += 1
	elif i % 2 == 0:
		if b[i] == 'r':
			x2 += 1
y2 = max(z2, x2)
if y1 <= y2:
	print(y1)
else:
	print(y2)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
n = int(ri())
s = ri()
s = [0 if i == 'r' else 1 for i in s]
(cnt1, cnt2) = (0, 0)
start = 1
for i in range(len(s)):
	if s[i] == start:
		start = start ^ 1
		continue
	elif s[i] == 0:
		cnt1 += 1
	else:
		cnt2 += 1
	start = start ^ 1
ans1 = max(cnt1, cnt2)
(cnt1, cnt2) = (0, 0)
start = 0
for i in range(len(s)):
	if s[i] == start:
		start = start ^ 1
		continue
	elif s[i] == 0:
		cnt1 += 1
	else:
		cnt2 += 1
	start = start ^ 1
ans2 = max(cnt1, cnt2)
print(min(ans1, ans2))


n = int(input())
a = input().strip()
even = a[::2]
odd = a[1::2]
c = 'rb'
ans = n
for i in range(2):
	x = len(even) - even.count(c[i])
	y = len(odd) - odd.count(c[i ^ 1])
	ans = min(ans, max(x, y))
print(ans)


from sys import *
n = int(stdin.readline())
s = stdin.readline()
(m1, m2, ans) = (0, 0, 0)
for i in range(len(s)):
	if i % 2 and s[i] == 'r':
		m1 += 1
	if not i % 2 and s[i] == 'b':
		m2 += 1
ans = max(m1, m2)
(m1, m2) = (0, 0)
for i in range(len(s)):
	if i % 2 and s[i] == 'b':
		m1 += 1
	if not i % 2 and s[i] == 'r':
		m2 += 1
print(min(ans, max(m1, m2)))


IL = lambda : list(map(int, input().split()))
IS = lambda : input().split()
I = lambda : int(input())
S = lambda : input()
n = I()
s = S()
rb = [s[i] == 'rb'[i % 2] for i in range(n)]
br = [s[i] == 'br'[i % 2] for i in range(n)]
ans = [0, 0]
mp0 = (rb[0::2].count(False), rb[1::2].count(False))
mp1 = (br[0::2].count(False), br[1::2].count(False))
print(min(max(mp0), max(mp1)))


n = int(input())
l = list(input())
(x1, x2, y1, y2) = (0, 0, 0, 0)
for i in range(n):
	if i % 2 == 0:
		if l[i] == 'r':
			x1 += 1
		else:
			x2 += 1
	elif l[i] == 'b':
		y1 += 1
	else:
		y2 += 1
print(min(max(x1, y1), max(x2, y2)))


n = int(input())
ar = list(input())
kek = 0
for i in range(n):
	if i % 2 == 0 and ar[i] == 'r':
		kek += 1
	if i % 2 == 1 and ar[i] == 'b':
		kek += 1
flag = 0
if n - kek < kek:
	kek = n - kek
	flag = 1
(a, b) = (0, 0)
for i in range(n):
	if flag == 0:
		if i % 2 == 0 and ar[i] == 'r':
			a += 1
		if i % 2 == 1 and ar[i] == 'b':
			b += 1
	else:
		if i % 2 == 0 and ar[i] == 'b':
			a += 1
		if i % 2 == 1 and ar[i] == 'r':
			b += 1
print(max(0, kek - min(a, b)))


n = int(input().strip())
a = list([{'r': 0, 'b': 1}[x] for x in input()])
cb = 0
cr = 0
ccb = 0
ccr = 0
for (i, c) in enumerate(a):
	cb += i & 1 & (c ^ 0)
	cr += ~(i & 1) & (c ^ 1)
	ccb += i & 1 & (c ^ 1)
	ccr += ~(i & 1) & (c ^ 0)
ans1 = cb + cr - min(cb, cr)
ans2 = ccb + ccr - min(ccb, ccr)
print(min(ans1, ans2))


n = int(input())
string = input()
(m11, m12, m21, m22) = (0, 0, 0, 0)
for i in range(n):
	if i % 2 == 0 and string[i] == 'b':
		m21 += 1
	elif i % 2 != 0 and string[i] == 'r':
		m22 += 1
	elif i % 2 == 0:
		m11 += 1
	else:
		m12 += 1
min1 = min(m21, m22)
(m21, m22) = (m21 - min1, m22 - min1)
r1 = max(m21, m22) + min1
min2 = min(m11, m12)
(m11, m12) = (m11 - min2, m12 - min2)
r2 = max(m11, m12) + min2
print(min(r1, r2))


n = int(input())
s = input()
a = [0] * n
for i in range(n):
	if s[i] == 'r':
		a[i] = 1
u = v = 0
for i in range(n):
	if i % 2 == 0:
		if a[i] != 1:
			u += 1
	elif a[i] != 0:
		v += 1
ans1 = max(u, v)
u = v = 0
for i in range(n):
	if i % 2 == 0:
		if a[i] != 0:
			u += 1
	elif a[i] != 1:
		v += 1
ans2 = max(u, v)
print(min(ans1, ans2))


def main():
	n = int(input())
	s = input()
	remain = [0] * 2
	for (i, x) in enumerate(s):
		if x == 'b' and i % 2 == 0 or (x == 'r' and i % 2 == 1):
			remain[i % 2] += 1
	diff = [n // 2 + (i % 2 == 0 and n % 2 == 1) - remain[i] for i in range(2)]
	print(min(max(diff), max([n // 2 + (i % 2 == 0 and n % 2 == 1) - diff[i] for i in range(2)])))
main()


n = int(input())
line = input()
b = r = 0
inverse_b = inverse_r = 0
flag = 0
for i in range(0, n):
	flag ^= 1
	if line[i] == 'b' and flag == 0:
		b += 1
	if line[i] == 'r' and flag == 1:
		r += 1
	if line[i] == 'b' and flag == 1:
		inverse_r += 1
	if line[i] == 'r' and flag == 0:
		inverse_b += 1
print(min(max(r, b), max(inverse_r, inverse_b)))


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
int1 = lambda x: int(x) - 1
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
ilelec = lambda : map(int1, input().split())
alelec = lambda : list(map(int1, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
N = int(input())
s = [*input()]
x = 'rb' * (N // 2 + 1)
y = 'br' * (N // 2 + 1)
mini = N
if N == 1:
	print(0)
	exit(0)

def fun(t):
	P = []
	Q = []
	for i in range(N):
		if s[i] != t[i]:
			if s[i] == 'b':
				P.append(i)
			else:
				Q.append(i)
	nn = max(len(P), len(Q))
	return nn
print(min(fun(x), fun(y)))


n = int(input())
s = input()
(ans11, ans12, ans21, ans22) = (0, 0, 0, 0)
for i in range(n):
	if i % 2 == 0:
		if s[i] == 'r':
			ans21 += 1
		if s[i] == 'b':
			ans12 += 1
	else:
		if s[i] == 'r':
			ans11 += 1
		if s[i] == 'b':
			ans22 += 1
print(min(max(ans11, ans12), max(ans21, ans22)))


from itertools import groupby
n = int(input())
s = input()
ans1 = 0
ans2 = 0
for x in range(n):
	if x % 2 == 0:
		if s[x] == 'b':
			ans1 = ans1 + 1
	elif s[x] == 'r':
		ans2 = ans2 + 1
ans = min(ans1, ans2) + abs(ans1 - ans2)
ans1 = 0
ans2 = 0
for x in range(n):
	if x % 2 == 0:
		if s[x] == 'r':
			ans1 = ans1 + 1
	elif s[x] == 'b':
		ans2 = ans2 + 1
ans = min(ans, min(ans1, ans2) + abs(ans1 - ans2))
print(ans)


n = int(input())
mas1 = input()
mas = []
for i in range(n):
	mas.append(mas1[i])

def calc(t):
	v = []
	res = []
	g = 0
	for i in range(n):
		if mas[i] != t:
			v.append(mas[i])
			g = 1
		elif g == 1:
			res.append(v)
			v = []
			g = 0
		if t == 'r':
			t = 'b'
		else:
			t = 'r'
	res.append(v)
	S = 0
	res1 = []
	for i in range(len(res)):
		t = len(res[i])
		if t % 2 != 0:
			p = res[i].count('r')
			w = res[i].count('b')
			if p > w:
				res1.append('r')
			else:
				res1.append('b')
		S = S + t // 2
	p = res1.count('r')
	w = res1.count('b')
	if p > w:
		S = S + p
	else:
		S = S + w
	return S
S1 = calc('b')
S = calc('r')
if S1 < S:
	print(S1)
else:
	print(S)


(n, s) = (int(input()), input())
(a, b) = (s[::2].count('r'), s[1::2].count('r'))
print(min(max((n + 1) // 2 - a, b), max(a, n // 2 - b)))


n = int(input())
s = input()
r_p = 0
r_i = 0
b_p = 0
b_i = 0
for i in range(n):
	if i % 2 == 0:
		if s[i] == 'b':
			b_p += 1
		else:
			r_p += 1
	elif s[i] == 'b':
		b_i += 1
	else:
		r_i += 1
m1 = min(r_i, b_p)
sol1 = b_p - m1 + r_i - m1 + m1
m2 = min(b_i, r_p)
sol2 = b_i - m2 + r_p - m2 + m2
print(min(sol1, sol2))


__author__ = 'Think'
n = int(input())
initial = input()
roaches = {(0, 'r'): 0, (0, 'b'): 0, (1, 'r'): 0, (1, 'b'): 0}
for i in range(n):
	roaches[i % 2, initial[i]] += 1
print(min(max(roaches[0, 'r'], roaches[1, 'b']), max(roaches[1, 'r'], roaches[0, 'b'])))


n = int(input())
st = input()
bfirstbwrong = 0
bfirstrwrong = 0
rfirstbwrong = 0
rfirstrwrong = 0
for i in range(len(st)):
	ch = st[i]
	if i % 2 == 0:
		if ch == 'b':
			rfirstbwrong += 1
		else:
			bfirstrwrong += 1
	elif ch == 'b':
		bfirstbwrong += 1
	else:
		rfirstrwrong += 1
banswer = max(bfirstbwrong, bfirstrwrong)
ranswer = max(rfirstbwrong, rfirstrwrong)
print(min(banswer, ranswer))


class CodeforcesTask719BSolution:

	def __init__(self):
		self.result = ''
		self.order = ''

	def read_input(self):
		input()
		self.order = input()

	def process_task(self):
		x = 0
		y = 0
		for (i, a) in enumerate(self.order):
			if i % 2 and a != 'b':
				x += 1
			elif not i % 2 and a != 'r':
				y += 1
		ans1 = max(x, y)
		x = 0
		y = 0
		for (i, a) in enumerate(self.order):
			if i % 2 and a != 'r':
				x += 1
			elif not i % 2 and a != 'b':
				y += 1
		ans2 = max(x, y)
		self.result = str(min(ans1, ans2))

	def get_result(self):
		return self.result
Solution = CodeforcesTask719BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
s = input()
s = list(s)
sr = ['r', 'b'] * (n // 2)
sb = ['b', 'r'] * (n // 2)
if n % 2 == 1:
	sr.append('r')
	sb.append('b')
(kb, kr) = (0, 0)
for i in range(n):
	if s[i] != sr[i]:
		if s[i] == 'b':
			kb += 1
		else:
			kr += 1
u1 = min(kb, kr) + max(kb, kr) - min(kb, kr)
(kb, kr) = (0, 0)
for i in range(n):
	if s[i] != sb[i]:
		if s[i] == 'b':
			kb += 1
		else:
			kr += 1
u2 = min(kb, kr) + max(kb, kr) - min(kb, kr)
print(min(u1, u2))


n = int(input())
xs = input()
(r1, r2, b1, b2) = (0, 0, 0, 0)
for (i, c) in enumerate(xs):
	if i % 2 == 0:
		if c == 'r':
			r1 += 1
		else:
			b2 += 1
	elif c == 'r':
		r2 += 1
	else:
		b1 += 1
print(min(max(r1, b1), max(r2, b2)))


n = int(input())
s = input()
(a_r, a_b) = (0, 0)
(b_r, b_b) = (0, 0)
for i in range(n):
	if i % 2 == 0:
		if s[i] == 'r':
			a_r += 1
		else:
			b_b += 1
	elif s[i] == 'b':
		a_b += 1
	else:
		b_r += 1
print(min(max(a_r, a_b), max(b_r, b_b)))


import logging
import copy
import sys
import math
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)

def solve(line):
	length = len(line)
	if length < 2:
		return 0
	diff = [0, 0]
	color = [line[0], 'b']
	if line[0] == 'r':
		color[1] = 'b'
	else:
		color[1] = 'r'
	color2 = [color[1], color[0]]
	diff2 = [0, 0]
	for (i, c) in enumerate(line):
		idx = i % 2
		if c != color[idx]:
			diff[idx] += 1
		if c != color2[idx]:
			diff2[idx] += 1
	return min([max(diff), max(diff2)])

def main():
	firstLine = int(input())
	line = input()
	print(solve(line))

def log(*message):
	logging.debug(message)
main()


(n, cr) = (int(input()), [i for i in input()])
cases = [(['r', 'b'] * int(n / 2 + 1))[0:n], (['b', 'r'] * int(n / 2 + 1))[0:n]]
ans = []
for case in cases:
	(btor, rtob) = (0, 0)
	for i in range(len(cr)):
		if cr[i] != case[i]:
			if cr[i] == 'r':
				rtob += 1
			else:
				btor += 1
	ans.append(min([rtob, btor]) + abs(rtob - btor))
print(min(ans))


n = int(input())
s = input()

def mainW(firstB):
	(bf, rf) = (0, 0)
	sb_b = firstB
	for c in s:
		if c == 'r' and sb_b:
			rf += 1
		elif c == 'b' and (not sb_b):
			bf += 1
		sb_b = not sb_b
	return min(bf, rf) + (max(bf, rf) - min(rf, bf))
print(min(mainW(True), mainW(False)))


n = int(input())
m = input()
rb = {'r': 0, 'b': 0}
br = {'r': 0, 'b': 0}
for i in range(n):
	if i % 2:
		if m[i] == 'b':
			br['b'] += 1
		else:
			rb['r'] += 1
	elif m[i] == 'r':
		br['r'] += 1
	else:
		rb['b'] += 1
rbs = min(rb['b'], rb['r']) + abs(rb['b'] - rb['r'])
brs = min(br['b'], br['r']) + abs(br['b'] - br['r'])
print(min(rbs, brs))


n = int(input())
a = input()
b = 'rb' * n
c = 'br' * n
bb = 0
cc = 0
for i in range(n):
	if a[i] == b[i]:
		bb += 1
	if c[i] == a[i]:
		cc += 1
if bb > cc:
	q = 0
	w = 0
	for i in range(n):
		if i % 2 == 0:
			if a[i] == 'b':
				q += 1
		elif a[i] == 'r':
			w += 1
	if q > w:
		print(q)
	else:
		print(w)
else:
	q = 0
	w = 0
	for i in range(n):
		if i % 2 == 0:
			if a[i] == 'r':
				q += 1
		elif a[i] == 'b':
			w += 1
	if q > w:
		print(q)
	else:
		print(w)


n = int(input())
s = [_ for _ in input()]
p = ['b', 'r']
b2 = []
b1 = []
for i in range(n):
	b1.append(p[i % 2])
	b2.append(p[(i + 1) % 2])
x = y = 0
for i in range(n):
	if s[i] != b1[i] and b1[i] == 'b':
		x += 1
	if s[i] != b1[i] and b1[i] == 'r':
		y += 1
k1 = max(x, y)
x = y = 0
for i in range(n):
	if s[i] != b2[i] and b2[i] == 'b':
		x += 1
	if s[i] != b2[i] and b2[i] == 'r':
		y += 1
k2 = max(x, y)
print(min(k1, k2))


am = int(input())
arr = list(input())
for i in range(am):
	if arr[i] == 'r':
		arr[i] = 1
	else:
		arr[i] = 0
ans = 0
onesWrong = 0
nullsWrong = 0
for i in range(am):
	if arr[i] != i % 2:
		if arr[i]:
			onesWrong += 1
		else:
			nullsWrong += 1
ans = min(onesWrong, nullsWrong) + (max(onesWrong, nullsWrong) - min(onesWrong, nullsWrong))
onesWrong = 0
nullsWrong = 0
for i in range(am):
	if arr[i] != (i % 2 + 1) % 2:
		if arr[i]:
			onesWrong += 1
		else:
			nullsWrong += 1
ans = min(min(onesWrong, nullsWrong) + (max(onesWrong, nullsWrong) - min(onesWrong, nullsWrong)), ans)
print(ans)


def makeAns(turn):
	qtdRed = 0
	qtdBlack = 0
	for c in crock:
		if c == 'r' and turn == 1:
			qtdRed += 1
		elif c == 'b' and turn == 0:
			qtdBlack += 1
		turn = (turn + 1) % 2
	return max(qtdRed, qtdBlack)

def verifica(lista):
	curr = lista[0]
	for i in range(1, len(lista)):
		if curr == 'r' and (not lista[i] == 'b'):
			return False
		elif curr == 'b' and (not lista[i] == 'r'):
			return False
		else:
			curr = lista[i]
	return True
n = int(input())
crock = list(input())
if verifica(crock):
	print(0)
else:
	print(min(makeAns(0), makeAns(1)))


while True:
	try:
		n = int(input())
		line = input()
		lenght = len(line)
		cpline1 = ['r', 'b'] * (lenght // 2 + 1)
		cpline2 = ['b', 'r'] * (lenght // 2 + 1)
		(dr1, db1) = (0, 0)
		for i in range(lenght):
			if line[i] != cpline1[i]:
				if line[i] == 'r':
					dr1 += 1
				else:
					db1 += 1
		ans1 = max(dr1, db1)
		(dr2, db2) = (0, 0)
		for i in range(lenght):
			if line[i] != cpline2[i]:
				if line[i] == 'r':
					dr2 += 1
				else:
					db2 += 1
		ans2 = max(dr2, db2)
		print(min(ans1, ans2))
	except EOFError:
		break


n = int(input())
a = [[0, 0] for _ in range(2)]
for (i, c) in enumerate(input().rstrip()):
	a[i & 1][c == 'r'] += 1
print(min(max(a[0][0], a[1][1]), max(a[1][0], a[0][1])))


import sys
n = int(int(input()))
s = input()
if n % 2 == 0:
	s2 = 'rb' * int(n / 2)
	s3 = 'br' * int(n / 2)
else:
	s2 = 'rb' * int(n / 2) + 'r'
	s3 = 'br' * int(n / 2) + 'b'
rcnt = bcnt = rcnt2 = bcnt2 = 0
for i in range(n):
	if s[i] != s2[i] and s2[i] == 'r':
		rcnt += 1
	elif s[i] != s2[i] and s2[i] == 'b':
		bcnt += 1
	if s[i] != s3[i] and s3[i] == 'r':
		rcnt2 += 1
	elif s[i] != s3[i] and s3[i] == 'b':
		bcnt2 += 1
cnt = max(rcnt, bcnt)
cnt2 = max(rcnt2, bcnt2)
print(min(cnt, cnt2))


from collections import Counter, defaultdict, deque
n = int(input())
if n == 1:
	print(0)
	exit()
c = 0
arr = [x for x in input()] + ['a', 'a']
v1 = 'rb' * (n // 2) + 'r' * (n % 2)
(r1, r2, b1, b2) = (0, 0, 0, 0)
for i in range(n):
	if arr[i] == 'r':
		if v1[i] == 'b':
			b1 += 1
		else:
			b2 += 1
	elif v1[i] == 'r':
		r1 += 1
	else:
		r2 += 1
print(min(max(r1, b1), max(r2, b2)))


n = int(input())
s = input()
cnt1 = 0
cnt2 = 0
cnt3 = 0
cnt4 = 0
for i in range(0, n):
	if i % 2 == 0:
		if s[i] == 'r':
			cnt1 = cnt1 + 1
		elif s[i] == 'b':
			cnt2 = cnt2 + 1
	elif s[i] == 'r':
		cnt3 = cnt3 + 1
	elif s[i] == 'b':
		cnt4 = cnt4 + 1
print(min(max(cnt1, cnt4), max(cnt2, cnt3)))


n = int(input())
s = str(input())

def get_for(c):
	w = [0, 0]
	for i in range(len(s)):
		if s[i] != c:
			w[i % 2] += 1
		c = 'r' if c == 'b' else 'b'
	return max(w[0], w[1])
print(min(get_for('r'), get_for('b')))


n = int(input())
s = input()
srr = 0
srb = 0
sbr = 0
sbb = 0
ansr = 0
ansb = 0
ans = 0
for i in range(n):
	if s[i] == 'r':
		if (i + 1) % 2 == 0:
			srr += 1
		else:
			sbr += 1
	elif (i + 1) % 2 == 0:
		sbb += 1
	else:
		srb += 1
if srr + srb < sbr + sbb:
	(ansr, ansb) = (srr, srb)
else:
	(ansr, ansb) = (sbr, sbb)
x = min(ansr, ansb)
ans = x + (max(ansr, ansb) - x)
print(ans)


def f(first, s):
	second = 'r' if first == 'b' else 'b'
	alt = [first, second]
	error = [0, 0]
	for (i, ch) in enumerate(s):
		shouldbe = alt[i % 2]
		if ch != shouldbe:
			error[i % 2] += 1
	return max(error)

def main():
	n = int(input())
	s = input()
	print(min(f('r', s), f('b', s)))
main()


def calc(s, t):
	n = len(s)
	rb = 0
	br = 0
	for i in range(n):
		if s[i] == 'r' and t[i] == 'b':
			rb += 1
		elif s[i] == 'b' and t[i] == 'r':
			br += 1
	return max(rb, br)
n = int(input())
s = list(input())
t = []
for i in range(int(n / 2)):
	t.append('r')
	t.append('b')
if n % 2 > 0:
	t.append('r')
res = calc(s, t)
t.clear()
for i in range(int(n / 2)):
	t.append('b')
	t.append('r')
if n % 2 > 0:
	t.append('b')
res = min(res, calc(s, t))
print(res)


def fbf():
	bbad = 0
	rbad = 0
	for i in range(n):
		if i % 2 == 0 and a[i] == 'r':
			rbad += 1
		if i % 2 == 1 and a[i] == 'b':
			bbad += 1
	return max(bbad, rbad)

def frf():
	bbad = 0
	rbad = 0
	for i in range(n):
		if i % 2 == 1 and a[i] == 'r':
			rbad += 1
		if i % 2 == 0 and a[i] == 'b':
			bbad += 1
	return max(bbad, rbad)
n = int(input())
a = input()
print(min(fbf(), frf()))


def func1(n):
	if n % 2 == 0:
		return 'rb' * (n // 2)
	else:
		return 'rb' * ((n - 1) // 2) + 'r'

def func2(n):
	if n % 2 == 0:
		return 'br' * (n // 2)
	else:
		return 'br' * ((n - 1) // 2) + 'b'
n = int(input())
s = input()
x1 = func1(n)
x2 = func2(n)
(a1, a2) = ([], [])
i = 0
while i < n:
	if s[i] != x1[i]:
		a1.append(s[i])
	i += 1
j = 0
while j < n:
	if s[j] != x2[j]:
		a2.append(s[j])
	j += 1
(cnt1b, cnt1r) = (a1.count('b'), a1.count('r'))
(cnt2b, cnt2r) = (a2.count('b'), a2.count('r'))
if len(a1) < len(a2):
	print(max(cnt1b, cnt1r))
else:
	print(max(cnt2b, cnt2r))


import sys, copy
n = int(input())
roaches = list(input().strip())
roaches2 = copy.deepcopy(roaches)
b_swaps = 0
r_swaps = 0
for i in range(1, n):
	if roaches[i] == 'b':
		if roaches[i - 1] == 'b':
			roaches[i] = 'r'
			b_swaps += 1
	elif roaches[i - 1] == 'r':
		roaches[i] = 'b'
		r_swaps += 1
sol1 = max(r_swaps, b_swaps)
b_swaps = 0
r_swaps = 0
if roaches2[0] == 'b':
	roaches2[0] = 'r'
	b_swaps += 1
else:
	roaches2[0] = 'b'
	r_swaps += 1
for i in range(1, n):
	if roaches2[i] == 'b':
		if roaches2[i - 1] == 'b':
			roaches2[i] = 'r'
			b_swaps += 1
	elif roaches2[i - 1] == 'r':
		roaches2[i] = 'b'
		r_swaps += 1
sol2 = max(r_swaps, b_swaps)
print(sol1 if sol1 < sol2 else sol2)


n = int(input())
s = input()
r1 = 0
b1 = 0
r2 = 0
b2 = 0
for i in range(0, n):
	if s[i] == 'r' and i % 2 == 0:
		r1 += 1
	if s[i] == 'b' and i % 2 == 1:
		b1 += 1
	if s[i] == 'r' and i % 2 == 1:
		r2 += 1
	if s[i] == 'b' and i % 2 == 0:
		b2 += 1
x1 = max(r2, b2)
x2 = max(r1, b1)
print(min(x1, x2))


n = int(input())
s = input()
l1 = 'br' * (n // 2) + 'b' * (n % 2)
l2 = 'rb' * (n // 2) + 'r' * (n % 2)
b1 = [0] * (n // 2 + n % 2)
b2 = [0] * (n // 2)
r1 = [0] * (n // 2)
r2 = [0] * (n // 2 + n % 2)
counter1 = 0
counter2 = 0
m1 = 0
m2 = 0
k1 = 0
k2 = 0
for i in range(n):
	if l1[i] == s[i]:
		if i % 2 == 0:
			b1[m1] = 1
			m1 += 1
		else:
			r1[k1] = 1
			k1 += 1
	if l2[i] == s[i]:
		if i % 2 == 0:
			r2[m2] = 1
			m2 += 1
		else:
			b2[k2] = 1
			k2 += 1
a1 = b1.count(0)
a2 = r1.count(0)
counter1 = abs(a2 - a1) + min(a1, a2)
a1 = b2.count(0)
a2 = r2.count(0)
counter2 = abs(a2 - a1) + min(a1, a2)
print(min(counter1, counter2))


n = int(input())
s = input()
e = s[::2]
o = s[1::2]
c = n
for i in range(2):
	if i == 0:
		a = len(e) - e.count('r')
		b = len(o) - o.count('b')
	else:
		a = len(e) - e.count('b')
		b = len(o) - o.count('r')
	c = min(c, max(a, b))
print(c)


n = int(input())
s = input()
(x, y) = (0, 0)

def solve(a, b):
	(x, y) = (0, 0)
	for i in range(n):
		if i % 2 == 0:
			if s[i] != a:
				x += 1
		elif s[i] != b:
			y += 1
	return max(x, y)
ans = solve('r', 'b')
ans = min(ans, solve('b', 'r'))
print(ans)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
import time
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string
start_time = time.time()

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]

def get_ints():
	return map(int, sys.stdin.readline().split())
n = int(input())
s = input()
s1 = str()
ans1 = 0
for i in range(n):
	if i % 2 == 0:
		s1 += 'r'
	else:
		s1 += 'b'
ans1 -= abs(s.count('r') - s1.count('r'))
ans11 = abs(ans1)
for i in range(n):
	if s[i] != s1[i]:
		ans1 += 1
ans11 += ans1 // 2
s2 = str()
ans2 = 0
for i in range(n):
	if i % 2 == 0:
		s2 += 'b'
	else:
		s2 += 'r'
ans2 = 0
ans2 -= abs(s.count('r') - s2.count('r'))
ans22 = abs(ans2)
for i in range(n):
	if s[i] != s2[i]:
		ans2 += 1
ans22 += ans2 // 2
print(min(ans11, ans22))


import sys
n = int(input())
s = input()
t = ''
for i in range(n // 2):
	t += 'rb'
if n % 2 == 1:
	t += 'r'
r = 0
b = 0
for i in range(n):
	if s[i] != t[i]:
		if t[i] == 'r':
			r += 1
		else:
			b += 1
f = max(r, b)
t = ''
for i in range(n // 2):
	t += 'br'
if n % 2 == 1:
	t += 'b'
r = 0
b = 0
for i in range(n):
	if s[i] != t[i]:
		if t[i] == 'r':
			r += 1
		else:
			b += 1
print(min(f, max(r, b)))


length = int(input())
count1 = int(0)
count2 = int(0)
count3 = int(0)
count4 = int(0)
string = input()
for i in range(0, length):
	if i % 2 == 0:
		if string[i] != 'r':
			count1 += 1
		elif string[i] != 'b':
			count2 += 1
	elif string[i] == 'r':
		count3 += 1
	elif string[i] == 'b':
		count4 += 1
moves1 = int(max(count1, count3))
moves2 = int(max(count2, count4))
answer = int(min(moves1, moves2))
print(answer)


def miss(st, c):
	r = 0
	for i in range(0, n, 2):
		if st[i] != c[0]:
			r += 1
	b = 0
	for i in range(1, n, 2):
		if st[i] != c[1]:
			b += 1
	return max(r, b)
n = int(input())
s = input()
print(min(miss(s, 'rb'), miss(s, 'br')))


n = int(input())
s = str(input())
r = b = 0
m = 0
m2 = 0
for i in range(n):
	if s[i] == 'r':
		r += 1
	else:
		b += 1
if n % 2:
	if r > b:
		for i in range(n):
			if s[i] == 'b' and i % 2 == 0:
				m += 1
		for i in range(n):
			if s[i] == 'b' and i % 2:
				m2 += 1
		print(min(m + (n - 1) // 2 - b, m2 + (n + 1) // 2 - b))
	else:
		for i in range(n):
			if s[i] == 'r' and i % 2 == 0:
				m += 1
		for i in range(n):
			if s[i] == 'r' and i % 2:
				m2 += 1
		print(min(m + (n - 1) // 2 - r, m2 + (n + 1) // 2 - r))
elif r > b:
	for i in range(n):
		if s[i] == 'b' and i % 2 == 0:
			m += 1
	for i in range(n):
		if s[i] == 'b' and i % 2:
			m2 += 1
	print(min(m, m2) + n // 2 - b)
else:
	for i in range(n):
		if s[i] == 'r' and i % 2 == 0:
			m += 1
	for i in range(n):
		if s[i] == 'r' and i % 2:
			m2 += 1
	print(min(m, m2) + n // 2 - r)


n = input()
word = input()
c = 0
(sum1, sum2, sum3, sum4) = (0, 0, 0, 0)
for i in word:
	if c == 0:
		if i == 'r':
			sum1 += 1
		else:
			sum2 += 1
		c = 1
	else:
		if i == 'b':
			sum3 += 1
		else:
			sum4 += 1
		c = 0
print(min(max(sum1, sum3), max(sum2, sum4)))


n = int(input())
s = input()
ab = 0
ar = 0
ab1 = 0
ar1 = 0
if s[0] == 'b':
	for i in range(n):
		if (i + 1) % 2 == 1:
			if s[i] != 'b':
				ab += 1
		elif s[i] != 'r':
			ar += 1
	for i in range(n):
		if (i + 1) % 2 == 1:
			if s[i] != 'r':
				ar1 += 1
		elif s[i] != 'b':
			ab1 += 1
else:
	for i in range(n):
		if (i + 1) % 2 == 1:
			if s[i] != 'r':
				ab += 1
		elif s[i] != 'b':
			ar += 1
	for i in range(n):
		if (i + 1) % 2 == 1:
			if s[i] != 'b':
				ab1 += 1
		elif s[i] != 'r':
			ar1 += 1
if max(ab1, ar1) > max(ab, ar):
	print(max(ab, ar))
else:
	print(max(ab1, ar1))


(n, cr) = (int(input()), [i for i in input()])
case_1 = (['r', 'b'] * n)[0:n]
case_2 = (['b', 'r'] * n)[0:n]
(btor, rtob) = (0, 0)
ans = []
for i in range(len(cr)):
	if cr[i] != case_1[i]:
		if cr[i] == 'r':
			rtob += 1
		else:
			btor += 1
ans.append(min([rtob, btor]) + abs(rtob - btor))
(btor, rtob) = (0, 0)
for i in range(len(cr)):
	if cr[i] != case_2[i]:
		if cr[i] == 'r':
			rtob += 1
		else:
			btor += 1
ans.append(min([rtob, btor]) + abs(rtob - btor))
print(min(ans))


n = int(input())
a = input()

def calc(s, t):
	dm = {'r': 0, 'b': 1}
	ct = [0] * 2
	for i in range(n):
		if s[i] != t[i]:
			ct[dm[s[i]]] += 1
	return max(ct)
ans = [calc(a, ''.join(('rb'[i & 1] for i in range(n)))), calc(a, ''.join(('br'[i & 1] for i in range(n))))]
print(min(ans))


(n, s) = (int(input()), input())

def f(x):
	(a, b) = (s[::2].count(x[0]), s[1::2].count(x[1]))
	return min(a, b) + abs(a - b)
print(min(f('rb'), f('br')))


import sys
import math
import bisect

def solve(A):
	n = len(A)
	x = 0
	y = 0
	for i in range(n):
		if A[i] == 0 and i % 2 == 1:
			x += 1
		elif A[i] == 1 and i % 2 == 0:
			y += 1
	return max(x, y)

def main():
	n = int(input())
	A = []
	s = input()
	for c in s:
		if c == 'r':
			A.append(0)
		elif c == 'b':
			A.append(1)
	val1 = solve(A.copy())
	for i in range(n):
		A[i] ^= 1
	val2 = solve(A.copy())
	print(min(val1, val2))
main()


n = int(input())
w = input()
a_red = a_blue = b_red = 0
for i in range(n):
	if i % 2:
		a_red += w[i] == 'r'
	else:
		a_blue += w[i] == 'b'
		b_red += w[i] == 'r'
print(min(max(a_red, a_blue), max(b_red, n - a_red - a_blue - b_red)))


mod = 1000000007
MOD = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
it = lambda : tuple(map(int, input().split()))
ls = lambda : list(input())
n = ii()
s = ls()
s1 = 'br' * 10 ** 5
s2 = 'rb' * 10 ** 5
(b1, w1, b2, w2) = (0, 0, 0, 0)
for i in range(n):
	if s[i] != s1[i]:
		if s[i] == 'b':
			b1 += 1
		else:
			w1 += 1
	if s[i] != s2[i]:
		if s[i] == 'b':
			b2 += 1
		else:
			w2 += 1
print(min(max(b1, w1), max(b2, w2)))


import os
import sys
from io import BytesIO, IOBase
import math
from itertools import permutations
from decimal import Decimal, getcontext
getcontext().prec = 25
MOD = pow(10, 9) + 7
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
s = list(input())
a = b = c = d = 0
for i in range(n):
	if i % 2:
		if s[i] != 'r':
			a += 1
		if s[i] != 'b':
			d += 1
	else:
		if s[i] != 'r':
			c += 1
		if s[i] != 'b':
			b += 1
print(min(max(a, b), max(c, d)))


n = int(input())
s = input()
rb_b_wrong = rb_r_wrong = 0
br_b_wrong = br_r_wrong = 0
for i in range(n):
	if i % 2 == 0:
		if s[i] == 'b':
			rb_b_wrong += 1
		else:
			br_r_wrong += 1
	if i % 2 == 1:
		if s[i] == 'b':
			br_b_wrong += 1
		else:
			rb_r_wrong += 1
print(min(max(rb_b_wrong, rb_r_wrong), max(br_b_wrong, br_r_wrong)))


def f(p):
	cnt1 = sum((a[i] != p[i] == 1 for i in range(n)))
	cnt2 = sum((a[i] != p[i] == 0 for i in range(n)))
	res = max(cnt1, cnt2)
	return res
n = int(input())
a = [int(i == 'r') for i in input()]
p1 = [i % 2 for i in range(n)]
p2 = [(i + 1) % 2 for i in range(n)]
ans = min(f(p1), f(p2))
print(ans)


import sys
n = int(input())
if n == 1:
	print(0)
	sys.exit(0)
s = list(input())
s2 = [i for i in s]
c = 0
r = 0
b = 0
for i in range(n):
	if i % 2 == 1 and s[i] != 'r':
		b += 1
	if i % 2 == 0 and s[i] != 'b':
		r += 1
c1 = max(r, b)
r2 = 0
b2 = 0
for i in range(n):
	if i % 2 == 0 and s[i] != 'r':
		b2 += 1
	if i % 2 == 1 and s[i] != 'b':
		r2 += 1
c2 = max(r2, b2)
print(min(c1, c2))