N = int(input()) S = input() ans = N-S.index('#') v = -1 w = 0 for s in S[N-ans:]: v += 1 if s == '#' else -1 # v = max(-1, v) w = max(v, w) print(ans+w)