# n=int(input())
# s=list(input())
# s2=s[:]
# s2.reverse()
# c=0
# for i in range(len(s)):
#   a=s[i]
#   if a=='#':
#     if i!=len(s)-1 and s[i+1]=='.':
#       s[i+1]='#'
#       c+=1
# c2=0
# for i in range(len(s2)):
#   a=s2[i]
#   if a=='.':
#     if i!=len(s2)-1 and s2[i+1]=='#':
#       s2[i+1]='.'
#       c2+=1
# print(s,s2)
# print(min(c,c2))

n=int(input())
s=list(input())
l=[]
a=s[0]
b=a
c=1
for x in s[1:]+['a']:
  if a==x:
    c+=1
  else:
    a=x
    l.append(c)
    c=1
cx=0
if b=='#':
  for i in range(len(l)//2):
    cx+=(min(l[2*i],l[2*i+1]))
else:
  l2=l[1:]+[0]
  for i in range(len(l2)//2):
    cx+=(min(l2[2*i],l2[2*i+1]))
print(cx)