Buggy python submission (verdict: Runtime Error):
N=int(input())
S=list(input())
dot=0
sha=0
s_r=list(reversed(S))
#print(s_r)
for i in range(N):
    if S[i] == ".":
        dot=i
        #break
for i in range(N):
    if s_r[i] == "#":
        sha=i
        #break

count=0
#print(dot)#左から
#print(sha)#右から
count_a=0
count_b=0

for i in range(N):
    if i<dot and S[i]!=".":
        count_a+=1
for i in range(N):
    if i<sha and s_r[i]!="#":
        count_b+=1
#print(count)
if dot<=sha:
    c=count_a+count_b
else:
    d=min(count_a,count_b)

a=0
b=0

for i in range(N):
    if S[i]!=".":
        a+=1
    if S[i]!="#":
        b+=1

#print(count)
ans=min(a,b,c,d)
print(ans)



Fixed submission:
# 累積和次は倒す
N = int(input())
S = input()
ans = 10 ** 9
white = [0] * (N + 1)
black = [0] * (N + 1)

for i, c in enumerate(S):
    if c == ".":
        white[i + 1] = white[i] + 1
        black[i + 1] = black[i]
    else:
        white[i + 1] = white[i]
        black[i + 1] = black[i] + 1
# 累積和
ans = min(ans, black[N], white[N])

white_sum = white[N]

for i in range(1, N):
    a = white_sum - white[i]
    b = black[i]
    # a 境目より右領域にどれだけ白があるか，その白は黒に変更
    # b 境目より左領域にどれだけ黒があるか，その黒は白に変更
    cnt = a + b
    ans = min(ans, cnt)
print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
S=list(input())
dot=0
sha=0
s_r=list(reversed(S))
#print(s_r)
for i in range(N):
    if S[i] == ".":
        dot=i
        #break
for i in range(N):
    if s_r[i] == "#":
        sha=i
        #break

count=0
#print(dot)#左から
#print(sha)#右から
count_a=0
count_b=0

if dot<=sha:
    for i in range(N):
        if i<dot and S[i]!=".":
            count_a+=1
    for i in range(N):
        if i<sha and s_r[i]!="#":
            count_b+=1
    #print(count)
    c=count_a+count_b
else:
    d=min(count_a,count_b)

a=0
b=0

for i in range(N):
    if S[i]!=".":
        a+=1
    if S[i]!="#":
        b+=1

#print(count)
ans=min(a,b,c,d)
print(ans)



Fixed submission:
# 累積和次は倒す
N = int(input())
S = input()
ans = 10 ** 9
white = [0] * (N + 1)
black = [0] * (N + 1)

for i, c in enumerate(S):
    if c == ".":
        white[i + 1] = white[i] + 1
        black[i + 1] = black[i]
    else:
        white[i + 1] = white[i]
        black[i + 1] = black[i] + 1
# 累積和
ans = min(ans, black[N], white[N])

white_sum = white[N]

for i in range(1, N):
    a = white_sum - white[i]
    b = black[i]
    # a 境目より右領域にどれだけ白があるか，その白は黒に変更
    # b 境目より左領域にどれだけ黒があるか，その黒は白に変更
    cnt = a + b
    ans = min(ans, cnt)
print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
S=list(input())
dot=0
sha=0
s_r=list(reversed(S))
#print(s_r)
for i in range(N):
    if S[i] == ".":
        dot=i
        #break
for i in range(N):
    if s_r[i] == "#":
        sha=i
        #break

count=0
#print(dot)#左から
#print(sha)#右から
count_a=0
count_b=0

if dot<=sha:
    for i in range(N):
        if i<dot and S[i]!=".":
            count_a+=1
    for i in range(N):
        if i<sha and s_r[i]!="#":
            count_b+=1
    #print(count)
    c=count_a+count_b
else:
    d=min(count_a,count_b)

a=0
b=0

for i in range(N):
    if S[i]!=".":
        a+=1
    if S[i]!="#":
        b+=1

#print(count)
ans=min(a,b,c,d)
print(ans)



Fixed submission:
# 累積和次は倒す
N = int(input())
S = input()
ans = 10 ** 9
white = [0] * (N + 1)
black = [0] * (N + 1)

for i, c in enumerate(S):
    if c == ".":
        white[i + 1] = white[i] + 1
        black[i + 1] = black[i]
    else:
        white[i + 1] = white[i]
        black[i + 1] = black[i] + 1
# 累積和
ans = min(ans, black[N], white[N])

white_sum = white[N]

for i in range(1, N):
    a = white_sum - white[i]
    b = black[i]
    # a 境目より右領域にどれだけ白があるか，その白は黒に変更
    # b 境目より左領域にどれだけ黒があるか，その黒は白に変更
    cnt = a + b
    ans = min(ans, cnt)
print(ans)