166
rbbbbbbbbbbbbrbrrbbrbbbrbbbbbbbbbbrbbbbbbrbbbrbbbbbrbbbbbbbrbbbbbbbrbbrbbbbbbbbrbbbbbbbbbbbbbbrrbbbrbbbbbbbbbbbbbbrbrbbbbbbbbbbbrbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbb
 7
rrbrbrb
 1
r
 2
bb
 18
rrrrrrrrrrrrrrrrrb
 8
rbbrbrbr
 1
b
 13
rbbbrbrrbrrbb
 100
brbbbrrrbbrbrbbrbbrbbbbrbbrrbbbrrbbbbrbrbbbbbbbbbbbbbbbbrrrrbbbbrrrbbbbbbbrbrrbrbbbbrrrbbbbrbbrbbbrb
 2
rb
 2
rr
 2
br

70
 1
 0
 1
 8
 1
 0
 3
 34
 0
 1
 0

n = int(raw_input())
string = raw_input()
listo = [r for r in string]

def change(s):
    if s == 'r':
        return 'b'
    else:
        return 's'
tot = 0
if n == 2:
    if listo[0] == listo[1]:
        listo[1] = change(listo[1])
        tot += 1
elif n == 3:
    if listo[0] == listo[1] and listo[1] == listo[2]:
        listo[1] = change(listo[1])
        tot += 1
    elif listo[0] == listo[1] or listo[1] == listo[2]:
        listo = list(set(listo))
        listo.append(listo[0])
        tot += 1
else:
    b, r = 0, 0
    bigline = 0
    currentline = 0
    start, fin = 0, 0
    for i in range(0,len(listo)-1):
        if listo[i] != listo[i+1]:
            currentline += 1
            begin = i
        else:
            fin = i
            if currentline > bigline:
                bigline, currentline = currentline, 0
                start, end = begin, fin
    for j in range(start, 2, -1):
        if listo[j] != listo[j-1]:
            continue
        else:
            if listo[j-1] != listo[j-2]:
                listo[j-1], listo[j-2] = listo[j-2], listo[j-1]
            else:
                listo[j-1] = change(listo[j-1])
                if listo[j-1] == 'b':
                    b += 1
                else:
                    r += 1
            tot += 1
    if listo[0] == listo[1]:
        listo[0] = change(listo[0])
        tot += 1
        if listo[0] == 'b':
            b += 1
        else:
            r += 1
            
    for k in range(fin, -3):
        if listo[k] != listo[k+1]:
            continue
        else:
            if listo[k+1] != listo[k+2]:
                listo[k+1], listo[k+2] = listo[k+2], listo[k+1]
            else:
                listo[k+1] = change(listo[k+1])
                if listo[k+1] == 'b':
                    b += 1
                else:
                    r += 1
            tot += 1
    if listo[-1] == listo[-2]:
        listo[-1] = change(listo[-1])
        tot += 1
        if listo[-1] == 'b':
            b += 1
        else:
            r += 1
    tot -= min(r,b)
print tot
