n = int(input()) s = input() s = s[s.find("#"):] d = -1 for v in s[::-1]: if v == "#": d += 1 else: d = max(d-1, -1) print(len(s)+d)