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

d = []
s = S[0]
c = 1
for i in range(1,N):
    if s == S[i]:
        c += 1
    else:
        d.append(c)
        c = 1
        s = S[i]
d.append(c)
ans = 0
if S[-1] == "#":
    for i in range(2,len(d),2):
        ans += min(d[-i],d[-i-1])
else:
    for i in range(1,len(d),2):
        ans += min(d[-i],d[-i-1])
print(ans-1)
