n=int(input())
s = input()

post = ''
ans=0
data=[]

left = [0 for _ in range(len(s))]
right = [0 for _ in range(len(s))]

tmp=0
for i in range(len(s)):
    if s[i]=='#':
        tmp+=1
    elif tmp!= 0:
        left[i]=tmp
        tmp=0

tmp=0
for i in range(len(s)):
    if s[n-i-1]=='.':
        tmp+=1
    if n-i-1-1 >=0 and s[n-i-1-1]=="#":
        right[n-i-1] = tmp
        tmp=0

# print(left)
# print(right)

for i in range(n):
    if left[i]!=0:
        ans += min(left[i],right[i])

print(ans)