N = int(input()) A = list(input())[::-1]#混乱するから逆にする ans=0 nowKeep = 0 for i,a in enumerate(A,start=1): if a=='#': ans = nowKeep+i nowKeep+=1 else: nowKeep=max(0,nowKeep-1) print(ans)