Problem:


Score : 300 points

Problem Statement

There are N stones arranged in a row. Every stone is painted white or black.
A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.

Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.
Find the minimum number of stones that needs to be recolored.

Constraints

1 \leq N \leq 2\times 10^5

S is a string of length N consisting of . and #.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the minimum number of stones that needs to be recolored.

Sample Input 1

3
#.#

Sample Output 1

1

It is enough to change the color of the first stone to white.

Sample Input 2

5
#.##.

Sample Output 2

2

Sample Input 3

9
.........

Sample Output 3

0



Sample input:
3
#.#


Sample output:
1

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

S_t1 = [s for s in S]
c1 = 0
for i in range(1, len(S)):
  if S_t1[i-1]=='#' and S_t1[i]=='.':
    S_t1[i] = '#'
    c1 += 1
    
S_t2 = [s for s in S]
c2 = 0
for i in range(1, len(S),-1):
  if S_t2[i-1]=='#' and S_t2[i]=='.':
    S_t2[i-1] = '.'
    c2 += 1
    
print(min(c1, c2))

Submission status: Wrong Answer

Solution code:
#.を防ぐ〜
N = int(input())
S = input()

S_t1 = [s for s in S]
c1 = 0
for i in range(1, len(S)):
  if S_t1[i-1]=='#' and S_t1[i]=='.':
    S_t1[i] = '#'
    c1 += 1
    
S_t2 = [s for s in S]
c2 = 0
for i in range(1, len(S)):
  if S_t2[i-1]=='#' and S_t2[i]=='.':
    S_t2[i] = '#'
    c2 += 1
    
print(min(c1, c2))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
lS = list(S)

ans = N
for i in range(0, N):
    left = lS[:i].count('#')
    right = lS[i:].count('.')
    ans = min(ans, left+right)

if ans == N:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
lS = list(S)

ans = N
for i in range(1, N):
    left = lS[:i].count('#')
    right = lS[i:].count('.')
    ans = min(ans, left+right)

if ans == N:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:

N = int(input())
S = list(str(input()))
cnt = 0

for i in range(N-1):
    if S[i] == S[i+1]:
        pass
    else:
        cnt += 1
        if S[i+1] == '#':
           S[i+1] = '.'
        else:
            S[i+1] = '#'
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
c = S.count("#")
min = 100000
if S.count("#") == 0:
  min = 0
for i in range(N):
  if S[i] == "#":
    if min > S[i:].count("."):
    	min = S[i:].count(".")
  if len(S[i:]) == S.count("#"):
    break
  S = S.replace("#",".",1)
print(min)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
c = S.count("#")
min = 200000
if S.count("#") == 0:
  min = 0
for i in range(N):
  if S[i] == "#":
    if min > S[i:].count("."):
    	min = S[i:].count(".")
  S = S.replace("#",".",1)

print(min)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
count = []
for i in range(1,n+1):
    black = s[:i].count("#")
    white = s[i:].count(".")
    count.append(black+white)
    
print(min(count))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

countW = 0
countB = 0
flagW = False
flagB = False

for i in range(N):
    if not flagW:
        if S[i] == "#":
            flagW = True
    else:
        if S[i] == ".":
            countW += 1
    
    if not flagB:
        if S[-(i + 1)] == ".":
            flagB = True
    
    else:
        if S[-(i + 1)] == "#":
            countB += 1
            
if countB > countW:
    print(countW)
else:
    print(countB)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

countW = 0
countB = 0
flag = False

for s in S:
    if s == "#":
        countB += 1
    if not flag:
        if s == "#":
            flag = True
    else:
        if s == ".":
            countW += 1
if S[-1] == "#":
    countB -= 1
if countB > countW:
    print(countW)
else:
    print(countB)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

countW = 0
countB = 0
flag = False

for s in S:
    if s == "#":
        countB += 1
    if not flag:
        if s == "#":
            flag = True
    else:
        if s == ".":
            countW += 1

if countB > countW:
    print(countW)
else:
    print(countB)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

count = 0
flag = False

for s in S:
    if not flag:
        if s == "#":
            flag = True
    else:
        if s == ".":
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
S=S+"a"

count=0
stone=[]
x=len(S)
for i in range(0,x):
    if(S[i]=="#" and S[i+1]=="." ):
        count=count+1
        S=S.replace(S[i],"#")

stone.append(count)
print(min(stone))

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()

count=0
stone=[]
x=len(S)-1
for i in range(0,x):
    if(S[i]=="#" and S[i+1]=="." ):
        count=count+1
        S=S.replace(S[i],"#")

stone.append(count)
print(min(stone))

Submission status: Wrong Answer

Solution code:

n = int(input())
s = input()

min_num = n
white_num_left = 0
black_num_left = 0
white_num = s.count('.')
black_num = n - white_num


for i in range(n):
    if s[i] == '#':
        black_num_left += 1
    else:
        white_num_left += 1
    if min_num >= black_num_left + (white_num - white_num_left):
        min_num = black_num_left + (white_num - white_num_left)
print(min_num)

Submission status: Wrong Answer

Solution code:

n = int(input())
s = input()

min_num = n
white_num_left = 0
black_num_left = 0
white_num = s.count('.')
black_num = n - white_num

if white_num == 0 or white_num == n:
    print(0)
else:
    for i in range(n):
        if s[i] == '#':
            black_num_left += 1
        else:
            white_num_left += 1
        if min_num >= black_num_left + (white_num - white_num_left):
            min_num = black_num_left + (white_num - white_num_left)
    print(min_num)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

min_num = n
white_num = s.count('.')
black_num = 0

if white_num == n or s.count('#') == n:
    print(0)
else:
    for i in range(n):
        if s[i] == '#':
            black_num += 1
        else:
            white_num -= 1
        if min_num >= black_num + white_num:
            min_num = black_num + white_num
    print(min_num)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
c = 0
for i in range(N):
    if i != N-1:
        if S[i] == '#' and S[i+1] == '.':
            c += 1
    else:
        pass
print(c)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
count = 0
ans = []
b_num = 0
w_num = 0
w_all = S.count('.')
for i in range(N):
  if S[i] == '#':
    b_num += 1
  if S[i] == '.':
    w_num += 1
  ans.append(w_all-w_num+b_num)
print(min(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
count = 0
count_b = []
count_w = []
b_num = 0
w_num = 0
w_all = S.count('.')
for i in range(N):
  if S[i] == '#':
    b_num += 1
  if S[i] == '.':
    w_num += 1
  count_w.append(w_all-w_num)
  count_b.append(b_num)
ans = 100000
for i in range(N):
  if ans > count_b[i]+count_w[i]:
    ans = count_b[i]+count_w[i]
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
b,w,ans=0,0,0
w=S.count('.')
ans=w
for i in S:
    if i=='#':
        b+=1
    else:
        w-=1 
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
count = 0
count_b = []
count_w = []
b_num = 0
w_num = 0
w_all = S.count('.')
for i in range(N):
  if S[i] == '#':
    b_num += 1
  if S[i] == '.':
    w_num += 1
  count_w.append(w_all-w_num)
  count_b.append(b_num)
ans = 100000
for i in range(N):
  if ans > count_b[i]+count_w[i]:
    ans = count_b[i]+count_w[i]

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
count = 0
count_b = []
count_w = []
b_num = 0
w_num = 0
w_all = S.count('.')
for i in range(N):
  if S[i] == '#':
    b_num += 1
  if S[i] == '.':
    w_num += 1
  count_w.append(w_all-w_num)
  count_b.append(b_num)
ans = 100000
for i in range(N):
  if ans > count_b[i]+w_all-count_w[i]:
    ans = count_b[i]+w_all-count_w[i]

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
count = 0
count_b = []
count_w = []
b_num = 0
w_num = 0
for i in range(N):
  if S[i] == '#':
    b_num += 1
  if S[i] == '.':
    w_num += 1
  count_w.append(w_num)
  count_b.append(b_num)
ans = 100000
for i in range(N):
  if ans > count_b[i]+count_w[i]:
    ans = count_b[i]+count_w[i]

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
ans=0
Slist=list(S)
S_changed=S
for i in range(N-1):
    if S[i]=="#" and S[i+1]==".":
            Slist[i+1]="."
            S_changed="".join(Slist)
            ans= ans+1
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
ans=0
for i in range(N-1):
    if S[i]=="#" and S[i+1]==".":
            ans= ans+1
print(ans)

Submission status: Wrong Answer

Solution code:
in_data = [input() for i in range(2)]

n = int(in_data[0])
s = in_data[1]


num_w = s.count('.')
num_b = s.count('#')
left_top = s[0] 
right_top = s[n - 1]
change_num = 0

if num_w == n: # 全て白なら
    change_num = 0
elif num_b == n: # 全て黒なら 
    change_num = 0
else:
    if num_w < num_b: # この場合，左端から連続している白を除く全ての白の場所を黒にする
        first_w = s.find('.')
        first_b = s.find('#')
        if s[first_w:].count('.') > s[first_w:].count('#'):
            change_num = s[first_w:].count('#')
        else:
            change_num = s[first_b:].count('.')
    elif num_w >= num_b: #この場合，右端から連続している黒を除く全ての黒の場所を白にする
        first_b = s.find('#')
        last_w = s.rfind('.')
        if s[first_b:].count('#') > s[first_b:].count('.'):
            change_num = s[first_b:].count('.')
        else:
            change_num = s[:last_w].count('#')

print(change_num)

Submission status: Wrong Answer

Solution code:
in_data = [input() for i in range(2)]

n = int(in_data[0])
s = in_data[1]
 
num_w = s.count('.')
num_b = s.count('#')
left_top = s[0] 
right_top = s[n - 1]
change_num = 0

if num_w == n: # 全て白なら
    change_num = 0
elif num_b == n: # 全て黒なら 
    change_num = 0
else:
    if num_w < num_b: # この場合，左端から連続している白を除く全ての白の場所を黒にする
        first_b = s.find('#')
        change_num = s[first_b:].count('.')
    elif num_w >= num_b: #この場合，右端から連続している黒を除く全ての黒の場所を白にする
        last_w = s.rfind('.')
        change_num = s[:last_w].count('#')

print(change_num)

Submission status: Wrong Answer

Solution code:
in_data = [input() for i in range(2)]

n = int(in_data[0])
s = in_data[1]
 
num_w = s.count('.')
num_b = s.count('#')
left_top = s[0] 
right_top = s[n - 1]
change_num = 0
 
if num_w == n: # 全て白なら
    change_num = 0
elif num_b == n: # 全て黒なら 
    change_num = 0
else:
    if num_w < num_b: # この場合，左端を除く全ての白の場所を黒にする
        change_num = s[1:].count('.')
    elif num_w >= num_b: #この場合，右端を除く全ての黒の場所を白にする
        change_num = s[:-1].count('#')
 
print(change_num)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

s = [0 for _ in range(N+1)]
for i, x in enumerate(S):
    if x == "#":
        s[i+1] = s[i] + 1
    else:
        s[i+1] = s[i]
num = N
for i in range(N):
    w = s[i] - s[0]
    b = (N - i) - (s[N] - s[i])
    if w + b < num:
        num = w + b
print(num)

Submission status: Wrong Answer

Solution code:
user_input=[]
for i in range(2):
    user_input.append(input())
N=int(user_input[0])
S=user_input[1]

S_list=[]
for i in S:
    S_list.append(i)

num=0
for i in range(N):
    if i < N-2:
        if S_list[i]=='#':
            if S_list[i+1]=='.':
                if S_list[i+2]=='#':
                    S_list[i+1]='#'
                    num=num+1
                elif S_list[i+2]=='.':
                    S_list[i]='.'
                    num=num+1
    elif i==N-2:
        if S_list[i]=='#':
            if S_list[i+1]=='.':
                S_list[i+1]='#'
                num=num+1        
print(num)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(input())
li=[]
count=0
for i in range(N):
    if S[i]==".":
        count+=1
    elif S[i]=="#":
        li.append(count)
        count=0
li.append(count)
del li[0]
print(min(sum(li),S.count("#")))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
x = 0
y = 0
 
for i in range(N):
  if S[i] == ".":
    x += 1
  else:
    y += 1
    
if x == 0 and y == 0:
  print(0)
elif x < y:
  print(x)
else:
  print(y)

Submission status: Wrong Answer

Solution code:
import re


# イテレーションのため
input()
S = input()

print(len(re.findall('(\#\.)', S)))

Submission status: Wrong Answer

Solution code:
import re


# イテレーションのため
input()
S = input()

print(len(re.findall('(#.)', S)))

Submission status: Wrong Answer

Solution code:

# -*- coding: utf-8 -*-
n = int(input())
s = list(input())

sum_w = [0]*(n+1)
sum_b = [0]*(n+1)

for i in range(n):
    if s[i] == '#':
        sum_b[i+1] = sum_b[i] + 1
    else:
        sum_b[i+1] = sum_b[i]

    if s[i] == '.':
        sum_w[i+1] = sum_w[i] + 1
    else:
        sum_w[i+1] = sum_w[i]

# 0番目からi番目までの黒の数
black = sum_b[i]
#  i+1番目からn番目(最後)までの白の数
white = sum_w[n]-sum_w[i]

ans = n
for i in range(n+1):
    ans = min(ans, black + white)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import sys
N = int(input())
s = input()
sh = []
dot = []
num = 0
for i in s:
    if i == '#':
        num += 1
        sh.append(num)
    else:
        sh.append(num)
num = 0
for i in s:
    if i == '.':
        num += 1
        dot.append(num)
    else :
        dot.append(num)
ans = 1e9
for i in range(N):
    tmp = sh[N-1] - sh[i] + dot[i]
    ans = min(ans, tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
N = input()
S = input()
print(min(S.count("."), S.count("#")))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = str(input())

out = 0

check = False

for i in range(len(s)):
    if s[i] == '#':
        check = True
    if s[i] == '.':
        if check == True:
            out += 1

print(out)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
bool = []
for i in s:
    if i == "#":
        bool.append(1)
    else:
        bool.append(0)
black = sum(bool)
bool_t = [0]
for i in range(n):
    bool_t.append(bool[i] + bool_t[i])
ans = float("inf")
for i in range(n):
    ans = min(ans, bool_t[i] + n - black - (i - bool_t[i]))
print(ans)

Submission status: Wrong Answer

Solution code:
user_input=[]
for i in range(2):
    user_input.append(input())
N=int(user_input[0])
S=user_input[1]

S_list=[]
for i in S:
    S_list.append(i)

num=0
for i in range(N-1):
    if S_list[i]=='#':
        if S_list[i+1]=='.':
            S_list[i+1]='#'
            num=num+1
print(num)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
bool = []
for i in s:
    if i == "#":
        bool.append(1)
    else:
        bool.append(0)
black = sum(bool)
bool_t = [0]
for i in range(n):
    bool_t.append(bool[i] + bool_t[i])
ans = float("inf")
for i in range(1, n + 1):
    ans = min(ans, bool_t[i] + n - black - (i + 1 - bool_t[i]))
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
bool = []
for i in s:
    if i == "#":
        bool.append(1)
    else:
        bool.append(0)
black = sum(bool)
bool_t = [0]
for i in range(n):
    bool_t.append(bool[i] + bool_t[i])
bool_t.pop(0)
ans = float("inf")
for i in range(n):
    ans = min(ans, bool_t[i] + n - black - (i + 1 - bool_t[i]))
print(ans)

Submission status: Wrong Answer

Solution code:
user_input=[]
for i in range(2):
    user_input.append(input())
N=int(user_input[0])
S=user_input[1]

S_list=[]
for i in S:
    S_list.append(i)

num=0
for i in range(N-1):
    if S_list[i]=='#':
        if S_list[i+1]=='.':
            num=num+1
print(num)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

WtoBcounter = 0
for i in range(N):
    if S[i] == "#":
        for j in range(i+1, N):
            if S[j] == ".":
                WtoBcounter += 1
        break

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

output = 0
if WtoBcounter < BtoWcounter:
    output = WtoBcounter
else:
    output = BtoWcounter

print(output)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

counter = 0
for i in range(N):
    if S[i] == "#":
        for j in range(i+1, N):
            if S[j] == ".":
                counter += 1
        break

print(counter)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

ans1 = s.count('#')
x = s.find('#')
if x == -1:
    ans2 = 0
else:
    ans2 = s[x+1:].count('.')
    
ans3 = n - ans1

print(min(ans1, ans2, ans3))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
"""
黒い石のすぐ右に白い石がない
すなわち
    最も左にある黒石よりも右に白石がない
    全て黒石
    全て白石
のいずれかを満たせば良い
それぞれの状態にするために変更する必要のある石の数をN_1, N_2, N_3とする
......#########
"""

N_1 = 0
N_2 = S.count(".")
N_3 = S.count("#")

black_left = 0
for i in range(N):
    if S[i] == "#":
        black_left = i
        break

N_1 = S[i:N].count(".")

print(min(N_1, N_2, N_3))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

ans1 = s.count('#')
x = s.find('#')
ans2 = s[x+1:].count('.')
ans3 = s.count('.')

print(min(ans1, ans2, ans3))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

ans1 = s.count('#')
x = s.find('#')
ans2 = s[x+1:].count('.')

print(min(ans1, ans2))

Submission status: Wrong Answer

Solution code:
input()
s = input()

white = s.count(".")
if white != 0:
  while s[-1] == '#':
    s = s[:-1]

print(min(white, s.count("#")))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
b = S.count(".")    # 黒に変えるべき石の数
w = 0               # 白に変えるべき石の数
ans = N

for i in range(N):
    if S[i] == "#":
        w += 1

    else:
        b -= 1
    t = w + b
    ans = min(ans, t)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
ans = N
for i in range(N+1):
    w = S[:i+1].count("#")
    b = S[N:i:-1].count(".")
    ans = min(ans, w+b)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
ans = N
for i in range(N):
    w = S[:i+1].count(".")
    b = S[N:i:-1].count("#")
    ans = min(ans, w+b)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
b = 0
w = 0
ans = N
bcount = []
wcount = []
for i in range(N):
    if S[i] == ".":
        w += 1
        wcount.append(w)
        bcount.append(b)
    elif S[i] == "#":
        b += 1
        wcount.append(w)
        bcount.append(b)
for i in range(N+1):
    x = sum(wcount[:i])
    y = sum(bcount[i::-1])
    ans = min(ans, x+y)

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(input())
a=S.count(".")
b=S.count("#")
print(N-max(a,b))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
 

if not '#' in S:
  print(0)
elif not '.' in S:
  print(0)
else:
  most_left_black = S.index('#')
  most_right_white = max([i for i, c in enumerate(S) if c == '.' ])

  def white2black(most_left_black):
    subS = S[most_left_black + 1:]
    num_to_replace = subS.count('.')
    return num_to_replace

  def black2white(most_right_white):
    subS = S[:most_right_white]
    num_to_replace = subS.count('#')
    return num_to_replace

  if most_right_white + 1 == most_left_black:
    print(0)
  else:
    print(min(white2black(most_left_black) , black2white(most_right_white)))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
 
def white2black():
  most_left_black = S.index('#')
  if most_left_black == len(S) - 1:
    return 0
  else:
    subS = S[most_left_black + 1:]
    num_to_replace = subS.count('.')
    return num_to_replace

def black2white():
  if not '.' in S:
    return 0
  else:
    most_right_white = max([i for i, c in enumerate(S) if c == '.' ])
    subS = S[:most_right_white]
    num_to_replace = subS.count('#')
    return num_to_replace
 
if not '#' in S:
  print(0)
else:
  print(min(white2black() , black2white()))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

if not '#' in S:
  print(0)
else:
  most_left_black = [c for c in S].index('#')

  if most_left_black == len(S) - 1:
    print(0)
  else:
    subS = S[most_left_black + 1:]
    num_to_replace = subS.count('.')
    print(num_to_replace)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
b = S.count('#')

if(b > N // 2):
    print(N - b - int(S[0] == '.'))

else:
    print(b - int(S[-1] == '#'))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
b = S.count('#')
 
if(b > N // 2):
    print(N - b)
 
else:
    print(b - int(S[-1] == '#'))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
b = S.count('#')

if(b >= N // 2):
    print(N - b)

else:
    print(b - int(S[-1] == '#'))

Submission status: Wrong Answer

Solution code:
N = input()
S = input()
a = int(N)
w=0
if S[-1]=='#':
  S = S[:-1]
  a -=1
for s in S:
  if s=='.':
    w +=1
print(min(a - w,w))

Submission status: Wrong Answer

Solution code:
N = input()
S = input()
a = int(N)
w=0
for s in S:
  if s=='.':
    w +=1

print(min(a - w,w))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N = int(input())
    S = input()

    if '#' not in S or '.' not in S:
        print(0)
        exit()

    b_num = 0
    w_num = S.count('.')
    ans = 10e6

    for i in range(N):
        ans = min(ans, b_num + w_num)
        if S[i] == '#':
            w_num += 1
        else:
            b_num -= 1

    print(ans)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N = int(input())
    S = input()

    if '#' not in S or '.' not in S:
        print(0)
        exit()

    b_num = 0
    w_num = S.count('.')
    ans = 10e6

    for i in range(N):
        ans = min(ans, b_num + w_num)
        if S[i] == '#':
            b_num -= 1
            w_num += 1

    print(ans)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N = int(input())
    S = input()

    if '#' not in S or '.' not in S:
        print(0)
        exit()

    b_num = S[1:].count('#')
    w_num = 0 if S[0] == '#' else 1
    # b_num = S.count('#')
    # w_num = 0
    ans = 10e6

    for i in range(N-1):
        ans = min(ans, b_num + w_num)
        if S[i] == '#':
            b_num -= 1
            w_num += 1

    print(ans)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N = int(input())
    S = input()

    if '#' not in S or '.' not in S:
        print(0)
        exit()

    b_num = S[1:].count('#')
    w_num = 0 if S[0] == '#' else 1
    ans = 10e6

    for i in range(N-1):
        ans = min(ans, b_num + w_num)
        if S[i] == '*':
            b_num -= 1
            w_num += 1

    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [1 if i == "." else 0 for i in input()]
# 黒は#,白が.
# 黒は0,白は1
# 黒の右に白は許されない
# ある場所を境に左は全部白、右は全部黒にするから、それの逆の個数を数える
# ある境より右にある白の数
rw = sum(S)
# ある境より左にある黒の数
lb = 0
min_temp = rw+lb
for idx,s in enumerate(S):
    # 黒の場合
    if s==0:
        # rw pass
        lb *= 1
    # 白の場合
    elif s==1:
        rw += 1
        lb -= 1
    # 小さい方を残す
    min_temp = min([min_temp,rw+lb])
    if min_temp == 0:break
print(min_temp)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

N = int(input())
S = input()

white = S.count('.')
black = N - white

l_white = 0
l_black = 0
r_white = white
r_black = black

cost = l_black + r_white

for s in S:
    if s == '.':
        l_white += 1
        r_white -= 1
    else:
        l_black += 1
        r_black -= 1
    print(l_white, l_black, r_white, r_black)
    cost = min(cost, l_black + r_white)
    
print(cost)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

white = S.count('.')
black = N - white

l_white = 0
l_black = 0
r_white = white
r_black = black

cost = 10**9

for s in S:
    if s == '.':
        l_white += 1
        r_white -= 1
    else:
        l_black += 1
        r_black += 1
    cost = min(cost, l_black + r_white)
    
print(cost)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
b = 0
w = s.count('.')
ans = w
for i in range(1, n):
    if s[i] == '.':
        w -= 1
    else:
        b += 1
    ans = min(ans, w + b)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
w = s[0].count('#')
b = s[1:].count('.')
ans = w
for i in range(1, n):
    if s[i] == '.':
        w -= 1
    else:
        b += 1
    ans = min(ans, w + b)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
ans = 999999999999999999
w = s[0].count('#')
b = s[1:].count('.')
ans = w + b
for i in range(1, n):
    if s[i] == '.':
        w -= 1
    else:
        b += 1
    ans = min(ans, w + b)
print(ans)

Submission status: Wrong Answer

Solution code:
input()

S = input()
flag  = False

ans1 = 0
for c in S:
    if c == '#':
        flag = True
    if not(flag):
        continue
    if c == '.':
        ans1 += 1
ans2 = 0
flag = False
for c in reversed(S):
    if c == '.':
        flag = True
    if not(flag):
        continue
    if c == '#':
        ans2 += 1


print(min(ans1,ans2))

Submission status: Wrong Answer

Solution code:
input()

S = input()
flag  = False

ans1 = 0
ans2 = 0
for c in S:
    if c == '#':
        flag = True
    if not(flag):
        ans2 +=1
        continue
    if c == '.':
        ans1 += 1


print(min(ans1,ans2))

Submission status: Wrong Answer

Solution code:
input()

S = input()
flag  = False

ans = 0
for c in S:
    if c == '#':
        flag = True
    if not(flag):
        continue
    if c == '.':
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

left_black = s[0].count('#')
right_white = s[1:].count('.')
suml = []
suml.append(left_black + right_white)
for i in range(1, n - 1):
    left_black = s[:i].count('#')
    right_white = s[i + 1:].count('.')
    suml.append(left_black + right_white)

if s.count('.') == n:
    print(0)
else:
    print(min(suml))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
S=list(s)
m=0
if S[0]=='#':
    for i in range(1,n):
        if S[i]=='.':
            m=m+1
        else:
            continue
                

else:
    for i in range(1,n):
        if S[i]=='.':
            if S[i-1]=='#':
                m=m+1
                S[i]='#'
            else:
                continue
        else:
            continue

print(m)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
S=list(s)
m=0

for i in range(1,n):
    if S[i]=='.':
        if S[i-1]=='#':
            m=m+1
            S[i]='#'
        else:
            continue
    else:
        continue

print(m)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
S=list(s)
siro=0
kuro=0

for i in range(0,n):
    if S[i]=='.':
        siro=siro+1
    else:
        kuro=kuro+1

if siro>kuro:
    print(kuro)
else:
    print(siro)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

for i in range(0, N):
    if S[i] == '#':
        a = S[i:].count('.')
        break
else:
    a = 0
print(min(S.count('#'), a))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

if S.count('#') > S.count('.'):
    for i in range(0, N):
        if S[i] == '#':
            print(S[i:].count('.'))
            break
else:
    print(S.count('#'))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

for i in range(0, N):
    if S[i] == '#':
        print(S[i:].count('.'))
        break
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

w = s.count(".")
b = s.count("#")

c = 0

if w <= (n // 2):
    for i in range(1,n):
        if s[0] + s[1] == "#.":
            c = s.count(".")
            break
        else:
            c = s[i:].count(".")
            break
else:
    for i in range(1,n):
        if s[i -1] + s[i] == "#.":
            c = s[i - 1:].count("#")
            break
print(c)

Submission status: Wrong Answer

Solution code:
N = input()
S = input()

if S.count('#') > S.count('.'):
    print(S.count('.'))
else:
    print(S.count('#'))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

w = s.count(".")
b = s.count("#")

c = 0

if w <= (n / 2):
    for i in range(1,n):
        if s[i - 1] + s[i] == "#.":
            c = s[i - 1:].count(".")
            break
else:
    for i in range(1,n):
        if s[i -1] + s[i] == "#.":
            c = s[i - 1:].count("#")
            break
print(c)

Submission status: Wrong Answer

Solution code:
N = int(input())
s=list(input())
cnt = 0
for i in range(N-1):
  if s[i]=='#' and s[i+1]=='.':
    s[i+1] = '#'
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
s=list(input())
cnt = 0
for i in range(N-1):
  if s[i]=='#' and s[i+1]=='.':
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
	
def main():
	N = int(input())
	S = input()
	
	if N == 1:
		print(0)
		sys.exit()
	
	kuro = []
	for i, val in enumerate(S):
		if i == 0:
			if val == "#":
				kuro.append(1)
			else:
				kuro.append(0)
			continue
		if val == "#":
			kuro.append(kuro[i-1] + 1)
		else:
			kuro.append(kuro[i-1])
	
	shiro = [0 for _ in range(N)]
	for i in range(N-1, -1, -1):
		if i == N-1:
			if S[i] == ".":
				shiro[i] = 1
			else:
				shiro[i] = 0
			continue
		if S[i] == ".":
			shiro[i] = shiro[i+1] + 1
		else:
			shiro[i] = shiro[i+1]
			
	ans = -1
	for i in range(N):
		tmp = -1
		if i == 0:
			tmp = shiro[0]
		elif i == N-1:
			tmp = kuro[N-1]
		else:
			tmp = kuro[i-1] + shiro[i]
		if ans > tmp or ans == -1:
			ans = tmp
	
	#print(kuro)
	#print(shiro)
	print(ans)
	
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

stones = []

for c in S:
    stones.append(c)

stones2 = stones.copy()

k = 0

for i,stone in enumerate(stones):
    if len(stones) > i + 1:
        if stone == "#":
            if stones[i+1] == ".":
                if len(stones) > i + 2 :
                    if stones[i+2] == ".":
                        stones[i] = "."
                    else:
                        stones[i] = "#"
                    k += 1
                else:
                    stones[i+1] = "#"
                    k += 1
print(k)