N = int(input())
S = input()
black = 0
white = 0
d = {}
for i in range(N):
  if S[i] == "#":
    black += 1
  elif S[i] == ".":
    white += 1
  if i == N-1:
    if S[i] == S[i-1]:
      d[i] = max(black, white)
    else:
      if S[i] == "#":
        d[i] = black
      else:
        d[i] = white
    break
  if S[i] == "#" and S[i+1] == ".":
    d[i] = black
    black = 0
  elif S[i] == "." and S[i+1] == "#":
    d[i] = white
    white = 0
d = sorted(d.items())
ans = 0
for i in range(len(d)-1):
  if S[d[i][0]] == "#" and S[d[i+1][0]] == ".": 
    ans += min(d[i][1], d[i+1][1])
print(ans)