mod = 998244353 def main(): import sys input = sys.stdin.readline N = int(input()) S = "." + input().rstrip('\n') cnt = 0 ans = 0 for i in range(-1, -N-1, -1): if S[i] == "#": cnt += 1 ans = max(ans, -i + cnt - 1) else: cnt = max(0, cnt - 1) print(ans) if __name__ == '__main__': main()