n = int(input())
s = list(input())
cums = []
count = 0
count_white = 0
count_black = 0

for i in range(len(s)):
  #count_white = 0
  #count_black = 0
  if s[i] == '.':
    count_white += 1
    if count_black != 0:
      cums.append(count_black)
      count_black = 0
  else:
    count_black -= 1
    if count_white != 0:
      cums.append(count_white)
      count_white = 0
if count_white != 0:
  cums.append(count_white)
if count_black != 0:
  cums.append(count_black)

ans = 0


#for i in range(len(cums)//2):
while len(cums) > 3:
  if abs(cums[0]) <= abs(cums[1]) and cums[0]*cums[1] < 0:
    ans += abs(cums[0])
    cums[1] += -cums[0]
    cums.pop(0)
  elif abs(cums[0]) >= abs(cums[1]) and cums[0]*cums[1] < 0:
    bw = '.'
    ans += abs(cums[1])
    cums[0] += -cums[1]
    cums.pop(1)
  else:
    cums[0] += cums[1]
    cums.pop(1)
  #count += min(cums[2*i], cums[2*i+1])

if cums[0]*cums[1] > 0 or cums[1]*cums[2] > 0:
  pass
else:
  if cums[0] > 0:
    a, b = cums[0], cums[2]
    if a < b:
      ans += a
    else:
      ans += b
  else:
    a, b = cums[0], cums[1]
    if abs(a) < abs(b):
      ans += abs(a)
    else:
      ans += abs(b)

print(ans)