N = int(input())
S = input()
ary = [0]
t = '.'
for s in S:
    if s == t:
        ary[-1] += 1
    else:
        ary.append(1)
        t = s
if t == '.':
    ary.append(0)
ans = 0
l = 1
r = len(ary)-2
while l < r:
    if ary[l] > ary[r]:
        ans += ary[r]
        r -= 1
    elif ary[l] == ary[r]:
        ans += ary[l]
        l += 1
        r -= 1
    else:
        ans += ary[l]
        l += 1
print(ans)
