Buggy python submission (verdict: Runtime Error):
from functools import reduce
l = int(input())
src = list(map(lambda x: 1 if x=="." else 0, input()))
lb = 0
rw = sum(src)
a = rw
for i in range(l):
  if src[i]==0:
    lb+=1
  else:
    rw-=1
  a = min(ans, lb + rw)
  if a==0:
    break
print(a)

Fixed submission:
from functools import reduce
l = int(input())
src = list(map(lambda x: 1 if x=="." else 0, input()))
left_black = 0
right_white = sum(src)
ans = right_white
for i in range(l):
  if src[i]==0:
    left_black+=1
  else:
    right_white-=1
  ans = min(ans, left_black + right_white)
  if ans==0:
    break
print(ans)

Buggy python submission (verdict: Runtime Error):
from functools import reduce
l = int(input())
src = list(map(lambda x: 1 if x=="." else 0, input()))
lb = 0
rw = sum(src)
a = rw
for i in range(l):
  if src[i]==0:
    lb+=1
  else:
    rw-=1
  a = min(ans, left_black + right_white)
  if ans==0:
    break
print(ans)

Fixed submission:
from functools import reduce
l = int(input())
src = list(map(lambda x: 1 if x=="." else 0, input()))
left_black = 0
right_white = sum(src)
ans = right_white
for i in range(l):
  if src[i]==0:
    left_black+=1
  else:
    right_white-=1
  ans = min(ans, left_black + right_white)
  if ans==0:
    break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
input()
src = list(map(lambda x: 1 if x=="#" else 0, input()))
s = sum(src)
l = len(src)
ans = s
for i in range(len(src)):
  ans = min(ans, 2*sum(src[:i]) + l - i - s)
  if ans==0:
    break
print(ans)

Fixed submission:
from functools import reduce
l = int(input())
src = list(map(lambda x: 1 if x=="." else 0, input()))
left_black = 0
right_white = sum(src)
ans = right_white
for i in range(l):
  if src[i]==0:
    left_black+=1
  else:
    right_white-=1
  ans = min(ans, left_black + right_white)
  if ans==0:
    break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
input()
src = list(map(lambda x: 1 if x=="#" else 0, input()))
ans = sum(src)
for i in range(len(src)):
  ans = min(ans, sum(src[:i]) + len(src[i:]) - sum(src[i:]))
  if ans==0:
    break
print(ans)

Fixed submission:
from functools import reduce
l = int(input())
src = list(map(lambda x: 1 if x=="." else 0, input()))
left_black = 0
right_white = sum(src)
ans = right_white
for i in range(l):
  if src[i]==0:
    left_black+=1
  else:
    right_white-=1
  ans = min(ans, left_black + right_white)
  if ans==0:
    break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
input()
src = list(map(lambda x: 1 if x=="#" else 0, input()))
costs = [sum(src[:i]) + len(src[i:]) - sum(src[i:]) for i in range(len(src))]
costs.append(sum(src))
print(min(costs))

Fixed submission:
from functools import reduce
l = int(input())
src = list(map(lambda x: 1 if x=="." else 0, input()))
left_black = 0
right_white = sum(src)
ans = right_white
for i in range(l):
  if src[i]==0:
    left_black+=1
  else:
    right_white-=1
  ans = min(ans, left_black + right_white)
  if ans==0:
    break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
input()
src = input()
costs = [reduce(lambda x,y: x+(1 if y=="#" else 0), src[:i], 0) + reduce(lambda x,y: x+(1 if y=="." else 0), src[i:], 0) for i in range(len(src))]
costs.append(reduce(lambda x,y: x+(1 if y=="#" else 0), src, 0))
print(min(costs))

Fixed submission:
from functools import reduce
l = int(input())
src = list(map(lambda x: 1 if x=="." else 0, input()))
left_black = 0
right_white = sum(src)
ans = right_white
for i in range(l):
  if src[i]==0:
    left_black+=1
  else:
    right_white-=1
  ans = min(ans, left_black + right_white)
  if ans==0:
    break
print(ans)