from copy import *
n = int(input())
s = list(input())
S = []
l = 0
for i in range(n-1):
    if s[i] != s[i+1]:
        S.append(s[l:i+1])
        l = i+1
if len(S) == 0:
    print(0)
else:
    if S[-1][0] == s[-1]:
        S[-1] += s[l:]
    else:
        S.append(s[l:])
    
    
    ans = 0
    m = len(S)
    
    if S[0][0] == '#':
        for i in range(m//2):
            ans += min(len(S[i*2]), len(S[i*2+1]))
    else:
        for i in range(m//2 - 1):
            ans += min(len(S[i*2+1]), len(S[i*2+2]))
    
    print(ans)