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: interview

Starter code:

Solutions:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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 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()))

N = int(input())
S = input()

# first: r
not_r = 0
not_b = 0
for i, s in enumerate(S):
    if i % 2 == 0:
        if s != "r":
            not_r += 1
    else:
        if s != "b":
            not_b += 1
ans = max(not_r, not_b)

# first: b
not_r = 0
not_b = 0
for i, s in enumerate(S):
    if i % 2 == 0:
        if s != "b":
            not_b += 1
    else:
        if s != "r":
            not_r += 1
ans = min(ans, max(not_r, not_b))
print(ans)


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
	else:
		if 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())
s = input()

cwred = 0
cwblack = 0

res = 0

#red first
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

#black first
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)





# You lost the game.

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

else:
    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,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 = 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)))

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())
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))

from math import ceil

n=int(input())
col=list(input())

nr=col.count('r')
nb=col.count('b')

dif=int(abs(nr-nb)/2)

c1=0
c2=0

for i in range(len(col)):
	if i%2==0:
		if col[i]=='b':
			c1+=1
		else:
			c2+=1
	else:
		if col[i]=='r':
			c1+=1
		else:
			c2+=1

c=min(c1,c2)

print(int(ceil((c-dif)/2))+dif)

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
		else:
			if s[i]!='r':
				ar+=1
	for i in range(n):
		if (i+1)%2==1:
			if s[i]!='r':
				ar1+=1
		else:
			if s[i]!='b':
				ab1+=1
else:
	for i in range(n):
		if (i+1)%2==1:
			if s[i]!='r':
				ab+=1
		else:	
			if s[i]!='b':
				ar+=1	
	for i in range(n):
		if (i+1)%2==1:
			if s[i]!='b':
				ab1+=1
		else:
			if s[i]!='r':
				ar1+=1
if max(ab1,ar1)>max(ab,ar):
	print(max(ab,ar))
else:
	print(max(ab1,ar1))

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

        
    



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 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
            else:
                if 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
            else:
                if rCo != 0:
                    rCo -= 1
                else:
                    bCo += 1
                    co += 1
            cur *= -1

    print(min(co, first))
    return 0

def __starting_point():
    B()
__starting_point()

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

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


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





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()
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

    else:
        if (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)

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


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
        else:
            if c == 'r':
                reven += 1
            else:
                beven += 1

    print((min(abs(bodd-reven) + min(bodd, reven),
              abs(rodd-beven) + min(rodd, beven))))
main()


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

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

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 = 0101010101010101
#a2 = 1010101010101010
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=input()
text=input()
switcher=-1
#b=1
#r=-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

#print('tc1-'+str(triecount)+'tc2-'+str(triecount2))
tc1=triecount
tc2=triecount2


if tc1<=tc2:
	print(tc1)
else:
	print(tc2)