N = int(input()) S = input() A = [0] * N i = 0 while S[i] == ".": i += 1 S = S[i:] N = len(S) for i, s in enumerate(S): if s == "#": A[i] = A[i - 1] + 1 else: A[i] = A[i - 1] - 1 x = S.index("#") y = max(A) print(N - x + y - 1)