N = int(input())
S = input()
s = S.replace('.#', '.0#').replace('#.', '#0.').split('0')

m = len(s)
p0 = s[0]
p1 = False
ans = 0

for i in range(1, m):
    if not p1:
        if i >= m - 1 and s[i][0] == '#':continue
        if i >= m - 1 and s[i][0] == '.':
            ans += min(len(s[i]), len(p0))
        p1 = s[i]
        continue
    if p0[0] == '#' and p1[0] == '.' and s[i][0] == '#':
        if len(p0) > len(p1):
            ans += len(p1)
            p0 = '#' * (len(p0) + len(p1) + len(s[i]))
            p1 = False
        else:
            ans += len(p0)
            p0 = '.' * (len(p0) + len(p1))
            p1 = s[i]
    elif p0[0] == '.' and p1[0] == '#' and s[i][0] == '.':
        if len(p1) >= len(s[i]):
            ans += len(s[i])
            p1 = '#' * (len(p1) + len(s[i]))
        else:
            ans += len(p1)
            p0 = '.' * (len(p0) + len(p1) + len(s[i]))
            p1 = False
        
print(ans)