Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())

white = 0
black = 0
ans = None

for i in range(N):
  white = S[0:i].count("#")
  black = S[i+1:N+1].count(".")
  if ans == None:
    ans = white+black
  else:
    ans = min(ans,white+black)

print(ans)


Fixed submission:
N = int(input())
S = str(input())

white = S.count(".")
black = 0
ans = S.count(".")

for i in range(N):
  if S[i] == ".":
    white -=1
  else:
    black +=1
  ans = min(ans,white+black)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())

white = 0
black = 0
index = 0

ans = []

for i in range(N):
  white = S[0:i].count("#")
  black = S[i+1:N+1].count(".")
  ans.append(white+black)

print(min(ans))


Fixed submission:
N = int(input())
S = str(input())

white = S.count(".")
black = 0
ans = S.count(".")

for i in range(N):
  if S[i] == ".":
    white -=1
  else:
    black +=1
  ans = min(ans,white+black)

print(ans)

Buggy python submission (verdict: Runtime Error):
 N = int(input())
 S = str(input())

 white = 0
 black = 0
 first_black_index = 0

 while S[first_black_index] == ".":
   first_black_index += 1
   if first_black_index == N:
     print(0)
     break

 last_black_index = N
 if first_black_index != N:
   while S[last_black_index-1] == "#":
     last_black_index -= 1
     if last_black_index == 0:
       print(0)
       break


 if first_black_index != N and last_black_index != 0:
   S = S[first_black_index:last_black_index]

   for i in range(len(S)):
     if S[i] == "#":
       black +=1
     else:
       white +=1

   print(min(white,black))


Fixed submission:
N = int(input())
S = str(input())

white = S.count(".")
black = 0
ans = S.count(".")

for i in range(N):
  if S[i] == ".":
    white -=1
  else:
    black +=1
  ans = min(ans,white+black)

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = str(input())

white = 0
black = 0
first_black_index = 0
end_index = N

while S[first_black_index] == ".":
  first_black_index += 1
  if first_black_index == N:
    print(0)
    break

last_black_index = len(S)
if first_black_index != N:
  while S[len(S)] == "#":
    last_black_index -= 1
    if last_black_index == 0:
      print(0)
      break


if first_black_index != N and last_black_index != 0:
  S = S[first_black_index:last_black_index+1]

  for i in range(len(S)):
    if S[i] == "#":
      black +=1
    else:
      white +=1

  print(min(white,black))


Fixed submission:
N = int(input())
S = str(input())

white = S.count(".")
black = 0
ans = S.count(".")

for i in range(N):
  if S[i] == ".":
    white -=1
  else:
    black +=1
  ans = min(ans,white+black)

print(ans)

Buggy python submission (verdict: Runtime Error):
 N = int(input())
 S = str(input())

 white = 0
 black = 0

 first_black_index = 0

 while S[first_black_index] == ".":
   first_black_index += 1
   if first_black_index == N:
     print(0)
     break
 if first_black_index != N:
   S = S[first_black_index:N+1]

   if S[len(S)-1] == "#":
     N = N-1


   for i in range(len(S)):
     if S[i] == "#":
       black +=1
     else:
       white +=1

   print(min(white,black))


Fixed submission:
N = int(input())
S = str(input())

white = S.count(".")
black = 0
ans = S.count(".")

for i in range(N):
  if S[i] == ".":
    white -=1
  else:
    black +=1
  ans = min(ans,white+black)

print(ans)