N = int(input())
S = input()
dif = 0
ans_i = 0
mem = -1
for i, char in enumerate(S):
    if char == '.':
        dif += 1
    else:
        dif -= 1
    if abs(dif) > mem:
        mem = abs(dif)
        ans_i = i
print(S[:ans_i+1].count('#') + S[ans_i+1:].count('.'))
