Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
 
ans = float("inf")
for i in range(len(S)+1):
  left = S[:i].count("#")
  right = S[i:].count(".")
  ans = min(ans, left + right)
  
print(ans)

Fixed submission:
N = int(input())
S = input()
 
left = 0
right = S.count(".")
ans = right

for i in range(len(S)):
    if S[i] == ".":
        right -= 1
    else:
        left += 1

    ans = min(ans, left + right)
  
print(ans)

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

if len(set(S)) == 1:
    print(0)
    quit()

a = S.count(".")
b = S.count("#")
ans2 = min(a,b)

ans = 0

if S[0] == "#":
    i = 1
    while True:
        if S[i] == ".":
            ans = i
            S = S[i:]
            break
        else:
            i += 1
else:
    flag = False
    for i in S:
        if i == "#":
            flag = True
        elif flag :
            break
    else:
        print(0)
        quit()

# if len(set(S)) == 1:
#     print(ans2)
#     quit()

if S[-1] == ".":
    i = 2
    while True:
        if S[-i] == "#":
            ans += (i-1)
            S = S[:-i+1]
            break
        else:
            i += 1


for i in range(len(S)):
    if S[i] == "#":
        S = S[i:]
        break
for i in range(1, len(S)+1):
    if S[-i] == ".":
        S = S[:-(i-1)]
        break

print(min(min(S.count("."), S.count("#")) + ans, ans2))

Fixed submission:
N = int(input())
S = input()
 
left = 0
right = S.count(".")
ans = right

for i in range(len(S)):
    if S[i] == ".":
        right -= 1
    else:
        left += 1

    ans = min(ans, left + right)
  
print(ans)

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

if len(set(S)) == 1:
    print(0)
    quit()

a = S.count(".")
b = S.count("#")
ans2 = min(a,b)

ans = 0

if S[0] == "#":
    i = 1
    while True:
        if S[i] == ".":
            ans = i
            S = S[i:]
            break
        else:
            i += 1
else:
    flag = False
    for i in S:
        if i == "#":
            flag = True
        if flag and i == ".":
            break
    else:
        print(0)
        quit()

if S[-1] == ".":
    i = 2
    while True:
        if S[-i] == "#":
            ans += (i-1)
            S = S[:-i+1]
            break
        else:
            i += 1


for i in range(len(S)):
    if S[i] == "#":
        S = S[i:]
        break
for i in range(1, len(S)+1):
    if S[-i] == ".":
        S = S[:-(i-1)]
        break

print(min(min(S.count("."), S.count("#")) + ans, ans2))


Fixed submission:
N = int(input())
S = input()
 
left = 0
right = S.count(".")
ans = right

for i in range(len(S)):
    if S[i] == ".":
        right -= 1
    else:
        left += 1

    ans = min(ans, left + right)
  
print(ans)

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

if len(set(S)) == 1:
    print(0)
    quit()



ans = 0

if S[0] == "#":
    i = 1
    while True:
        if S[i] == ".":
            ans = i
            S = S[i:]
            break
        else:
            i += 1
else:
    flag = False
    for i in S:
        if i == "#":
            flag = True
        if flag and i == ".":
            break
    else:
        print(0)
        quit()

if S[-1] == ".":
    i = 2
    while True:
        if S[-i] == "#":
            ans += (i-1)
            S = S[:-i+1]
            break
        else:
            i += 1


for i in range(len(S)):
    if S[i] == "#":
        S = S[i:]
        break
for i in range(1, len(S)+1):
    if S[-i] == ".":
        S = S[:-(i-1)]
        break


# odd = []
# even = []
# flag = False
# count = 1
# for i in range(1, len(S)):
#     if not S[i] == S[i-1]:
#         if not flag:
#             odd.append(count)
#         else:
#             even.append(count)
#         count = 1
#         flag = not flag
#     else:
#         count += 1
#
# if flag:
#     even.append(count)
# else:
#     odd.append(count)

# print(min(sum(odd), sum(even))+ans)

print(min(S.count("."), S.count("#")) + ans)


Fixed submission:
N = int(input())
S = input()
 
left = 0
right = S.count(".")
ans = right

for i in range(len(S)):
    if S[i] == ".":
        right -= 1
    else:
        left += 1

    ans = min(ans, left + right)
  
print(ans)

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

if len(set(S)) == 1:
    print(0)
    quit()



ans = 0

if S[0] == "#":
    i = 1
    while True:
        if S[i] == ".":
            ans = i
            S = S[i:]
            break
        else:
            i += 1
else:
    flag = False
    for i in S:
        if i == "#":
            flag = True
        if flag and i == ".":
            break
    else:
        print(0)
        quit()

if S[-1] == ".":
    i = 2
    while True:
        if S[-i] == "#":
            ans += (i-1)
            S = S[:-i+1]
            break
        else:
            i += 1


for i in range(len(S)):
    if S[i] == "#":
        S = S[i:]
        break
for i in range(1, len(S)+1):
    if S[-i] == ".":
        S = S[:-(i-1)]
        break


odd = []
even = []
flag = False
count = 1
for i in range(1, len(S)):
    if not S[i] == S[i-1]:
        if not flag:
            odd.append(count)
        else:
            even.append(count)
        count = 1
        flag = not flag
    else:
        count += 1

if flag:
    even.append(count)
else:
    odd.append(count)

print(min(sum(odd), sum(even))+ans)


Fixed submission:
N = int(input())
S = input()
 
left = 0
right = S.count(".")
ans = right

for i in range(len(S)):
    if S[i] == ".":
        right -= 1
    else:
        left += 1

    ans = min(ans, left + right)
  
print(ans)