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(input())
colors = input()
count_red = 0
pair_red = 0
pair_black = 0
count_black = 0
count_operation = 0
for i in range(n):
    if colors[i] == "b":
        count_black += 1
        if count_black > 1 and count_black != 3:
            count_operation += 1
            if count_black == 2:
                pair_black += 1
        elif count_black == 3:
            count_black = 1
            pair_black -= 1
        count_red = 0  
    else:
        count_red += 1
        if count_red > 1 and count_red != 3:
            count_operation += 1
            if count_red == 2:
                pair_red += 1
        elif count_red == 3:
            count_red = 1
            pair_red -= 1
        count_black = 0
count_operation -= min(pair_black, pair_red)
print(count_operation) 
        
    