def Run_Length_Encoding(S): """ランレングス圧縮 S:文字列 """ if not S: return [] R=[[S[0],1]] for i in range(1,len(S)): if R[-1][0]==S[i]: R[-1][1]+=1 else: R.append([S[i],1]) return R #================================================== N=int(input()) S=list(input()) a=0 ans=0 for i in range(N-1,-1,-1): if S[i]=="#": a+=1 ans=N-1-i+a else: a=max(a-1,0) print(ans)