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()

ans = 0
p = 0
q = 0
sai = 0
v = 0
w = 0
for i in range(n):
    if s[i] == "#" and sai == 0:
        p += 1
        v = 1
        sai = 1
    elif s[i] == "#" and v == 0:
        ans += min(p, q)
        p = 0
        q = 0
        w = 0
        p += 1
        v = 1
    elif s[i] == "#" and v == 1:
        p += 1
    elif s[i] == "." and w == 0 and sai == 1:
        v = 0
        q += 1
        w = 1
    elif s[i] == "." and w == 1:
        q += 1
ans += min(p, q)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
a = s.count(".")
b = s.count("#")
print(min(a, b))

Submission status: Wrong Answer

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

w = S.count('.')
b = S.count('#')

if w == 0 or b == 0:
    print(0)
    exit()

b1 = S.index('#')
S = S[::-1]
w1 = S.index('.')

print(min(b - w1, w - b1))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import re
import bisect
from datetime import datetime as dt
n = input()
s = raw_input()
s += '#'
c = 0
for i in range(n):
    if s[i] + s[i + 1] == '#.':
        c += 1
print c

Submission status: Wrong Answer

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

count = 0

for i in range(N-1):
  if S[i] == "#" and S[i+1] == ".":
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import sys

N = int(sys.stdin.readline().strip())
S = sys.stdin.readline().strip()

first = S[0]
array = []
count = 0
tmp = first

for s in S:
    if tmp == "#" and s == ".":
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
S = str(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:
def main():
	N = int(input())
	S = input()
	w = 0
	b = 0
	right_w = 0
	right_b = 0

	for i, c in enumerate(S):
		if c == ".":
			w += 1
			right_w = i
		else:
			b += 1
			right_b = i
	ans = min(w, b)
	if right_w < right_b:
		ans = min(ans, b-(right_b-right_w))
	print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
S = [str(c) for c in s]

cnt1 = 0; #　.の数
cnt2 = 0;#　#の数

for i in range(N):
    if str(S[i]) != ".":
        cnt1 += 1
    else:
        cnt2 += 1

if cnt1 >= cnt2:
    print(cnt2)
else:
    print(cnt1)

Submission status: Wrong Answer

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

count = 0

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

Submission status: Wrong Answer

Solution code:

if __name__ == '__main__':
    n = int(input())
    s = input()

    try:
        first_black = s.index('#')
    except ValueError as e:
        print(0)
        exit(0)

    s2 = s[first_black+1:]
    count = 0
    for c in s2:
        if c == '.':
            count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())
arg=0
for i in range(n):
    if s[i]=="#":
        arg=i
        break
ans=s[arg:].count(".")
ans_1=s.count("#")
print(ans if ans < ans_1 else ans_1)

Submission status: Wrong Answer

Solution code:
###
#main
if __name__ == "__main__":
    N = int(input())
    S = input()
    keepColor = False # True: need to change w -> b
    count = 0
    for t in S:
        if t == "#":
            keepColor = True
        if keepColor and t == ".":
            count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
# https://tenka1-2019-beginner.contest.atcoder.jp/tasks/tenka1_2019_c

import itertools
from collections import Counter
import bisect

def main():
    N = int(input())
    S = list(input())
    # print(S)

    first = -1
    for i in range(len(S)):
        if S[i] != '.':
            first = i
            break
    if first == -1: # all white
        print(0)
        exit()

    next_s = list(reversed(S[first:]))
    last = -1
    for i in range(len(next_s)):
        if next_s[i] != '#':
            last = i
            break
    if last == -1: # all black
        print(0)
        exit()

    next_s = next_s[last:]
    # 全部黒か全部白
    print(min(next_s.count('.'), next_s.count('#')))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

s_w = S.count('.')
s_b = S.count('#')

print(min(s_w,s_b))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = ['.'] + list(input()) + ['#']
ans = 0

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

Submission status: Wrong Answer

Solution code:
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")


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

if (S.count('.')==N) or (S.count('#')==N):
	print(0)
	exit()


#	s = "abc345abc"
#	print(s.find("a"))		#=> 0

i = S.find('#')
s = S[i:]

p(s)
p(s.count('.'))
p(s.count('#'))

ans = min(s.count('.'), S.count('#'))
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
if "#" in s:
  k=s.index("#")
  print(s[k:len(s)].count("."))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
s = [S[i: i + 1] for i in range(N)]
ans = 0
bflag = 0
for i, st in enumerate(s):
    if bflag == 1:
        if st == '.':
            ans += 1
        else:
            bflag = 0
    else:
        if st == '#':
            bflag = 1
print(ans)

Submission status: Wrong Answer

Solution code:
a=int(input())
b=input()
count=0
for i in range(1,a):
    if b[i-1]=="#" and b[i]==".":
        count+=1
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
numw=len([x for x in s if x=="#"])
numb=len([x for x in s if x=="."])
print(min(numb,numw))

Submission status: Wrong Answer

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

ans = 0
for i in range(len(S)-1):
  if S[i]=="#" and S[i+1]==".":
    ans += 1
    S = S[:i] + "#" + S[i+1:]
  
if 2*ans < len(S):
  print(ans)

else:
  print(len(S)-ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(1,N):
  if S[i] == '.' and S[i-1] == '#':
    ans += 1
    
print(ans)

Submission status: Wrong Answer

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

X = [0 if x == '#' else 1 for x in S]

if 0 not in X:
    ans = 0 
if 1 in X:
    ans = sum(X[X.index(1):])
else:
    ans = 0

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+=1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
for i in range(N):
    if S[i]=='#':
        print(S[i+1:].count('.'))
        exit()
print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

num_white = 0
num_black = 0
ans = 0
for i in range(N):
    if S[i] == '.':
        ans = num_black
        num_white += 1
    else:
        num_black += 1

print(ans if num_white >= ans else num_white)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
ans = 0
kuro = 0
if n==1:
    ans=0
if n ==2:
    if s=="#.":
        ans=1
else: 
    for i in s[1:-1]:
        if i=="#":
            kuro+=1
    siro=n-2-kuro
    if kuro>siro:
        ans+=siro
        if s[-1]==".":
            ans+=1
    elif kuro<siro:
        ans+=kuro
        if s[0]=="#":
            ans+=1
    else:
        ans+=kuro
        if s[0]=="#" or s[-1]==".":
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
flag = False
ans = 10 ** 6
count = 0
#白を黒に
for c in S:
    if c == "#":
        flag = True
    
    if c == "." and flag:
        count += 1

ans = min(ans, count)

count = 0

flag = False
for i in range(N-1, -1, -1):
    if S[i] == ".":
        flag = True

    if S[i] == "#" and flag:
        count += 1
    
ans = min(ans, count)

print(ans)

Submission status: Wrong Answer

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

flg = False
cnt = 0
for s in S:
    if not flg:
        if s=='#':
            flg = True
    else:
        if s=='.':
            cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
cta = 0
ctb = 0
ind1 = s.find('#')
ind2 = s.rfind('.')
for i in range(ind1+1,len(s)):
    if s[i] == '.':
        cta += 1
for i in range(ind2):
    if s[i] == '#':
        ctb += 1
print(min(cta,ctb))

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

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

c = 0
for i in range(1,n):
    if s[i - 1] == '#' and s[i] == '.':
        s[i] = '#'
        c += 1
print(c)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
s = list(s)
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 = input()

first_black = -1
for i in range(n):
    if s[i] == '#':
        first_black = i
        break

result = 0
if first_black > -1:
    for i in range(first_black, n):
        if s[i] == '.':
            result += 1

print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input().split(".")
nums = [i for i in S[:len(S)-1] if len(i)!=0]
print(len(nums))

Submission status: Wrong Answer

Solution code:
# coding: utf-8

import sys
input = sys.stdin.readline

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

a = S.count("#")
b = S.count(".")

print(min(a, b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
ans1 = 0
flag = False
for i in range(N):
    if S[i] == '#':
        flag = True
    elif flag and S[i] == '.':
        ans1 += 1
    else:
        pass

ans2 = 0
for i in reversed(range(N)):
    if S[i] == '.':
        flag = True
    elif flag and S[i] == '#':
        ans2 += 1
    else:
        pass

print(min(ans1,ans2))

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
cur=S.find("#")
if cur==-1:
	print(0)
else:
	print(S[cur:].count("."))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
f = S.find('#')
if f == -1:
    print(0)
else:
    cont = 0
    for i in range(f,N):
        if S[i] == '.':
            cont += 1
    print(cont)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
for i in range(N):
  if(i != 0):
    if((S[i-1] == '#')and(S[i] == '.')):
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
S_r = S[::-1]
ans = 0
flag = False
for char in S:
    if flag:
        if char == ".":
            ans += 1
            continue
        continue
    if char == "#":
        flag = True

ans_1 = 0
flag = False
for char in S_r:
    if flag:
        if char == "#":
            ans_1 += 1
            continue
        continue
    if char == ".":
        flag = True

print(min(ans,ans_1))

Submission status: Wrong Answer

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

N = int(input())
S = [x for x in input()]

cum_white = []
count = 0
for i, s in enumerate(S):
    if s == '.':
        count += 1
    cum_white.append(count)
    
if len(cum_white) == 0 or len(cum_white) == N:
    print(0)
else:
    min_num = int(1e10)
    for i, n_white in enumerate(cum_white):
        num = (i - n_white) + (N - cum_white[-1] - n_white)
        min_num = min(min_num, num)
        
    print(min_num)

Submission status: Wrong Answer

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


flag = False
c = 0
for i in range(N):
    if S[i] == '#':
        flag = True
    else:
        if flag:
            c += 1

print(c)

Submission status: Wrong Answer

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

if s.count('.') == n:
    print('0')
else:
    print(s[s.index('#'):].count('.'))

Submission status: Wrong Answer

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

if '.' not in S or '#' not in S:
  print(0)
  sys.exit()
  
bd = S.index('#')
print(S[bd:].count('.'))

Submission status: Wrong Answer

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

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

print(min(b,w))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
 
res = 0
tmp = ""
 
for i in S:
    if i == "." and tmp == "#":
        i == "#"
        res += 1
    tmp = i

print(res)

Submission status: Wrong Answer

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

post = ''
ans=0
for c in s:
    if c == "#":
        post = "#"
    if post == "#" and c == ".":
        ans+=1
        post='.'

print(ans)

Submission status: Wrong Answer

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

ans = 0

for i in range(len(s)-1):
	if(s[i] == "#" and s[i+1] == "."):
		s[i+1] = "#"
		ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
AtCoder C
"""
 
def main():
    N=input()
    S=list(map(str,input().split()))[0]
    tmp=False
    num=0
    for s in S:
        # print(s,tmp)
        if s=="#":
            tmp=True
        elif s=="." and tmp:
            num+=1
    num2=0
    for s in S:
        # print(s,tmp)
        if s=="#":
            num2+=1
    if S[-1]=="#":
        num-=1
    print(min(num,num2))
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
input = sys.stdin.readline

# bisect_left(lists, 3)
# bisect_right(lists, 3)

def main():
	N = int(input())
	S = input()

	ans = 0
	flg = False
	for i in S:
		if i == "#":
			flg = True
			continue
		if flg == True and i == ".":
			ans += 1

	print(ans)

	

	
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
import copy
n=int(input())
s_o=list(input())
s=copy.copy(s_o)
ans_1=0
ans_2=0
for i in range(n-1):
  if s[-i-1]=="." and s[-i-2]=="#":
    s[-i-2]="."
    ans_1+=1
flag=True
s=copy.copy(s_o)
for i in range(n-1):
  if flag==True:
    if s[-i-1]==".":
      s[-i-1]=="#"
      ans_2+=1
    else:
      flag=False
  else:
    if s[-i-1]=="." and s[-i-2]=="#":
      s[-i-2]="."
      ans_2+=1
print(min(ans_1,ans_2))

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
kuro = S.count("#")
shiro = S.count(".")
Slist =list(S)
if Slist[N-1] == "#":
	print(min(kuro-1,shiro))
else:
	print(min(kuro,shiro))

Submission status: Wrong Answer

Solution code:
#C
N=int(input())
S=input()
even = "#"*N
odd  = "." +"#"*(N-1)
odd2 = "."*N
eve_c=0
odd_c=0
odd_2=0
for i in range(N):
    if S[i]!=even[i]:
        eve_c+=1

    if S[i]!=odd[i]:
        odd_c+=1

    if S[i]!=odd2[i]:
        odd_2+=1

print(min(eve_c,odd_c,odd_2))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
first_black = -1
for i in range(N):
    if S[i] == "#":
        first_black = i
        break
if first_black == -1:
    print(0)
else:
    ans = min(S[first_black:].count("."), S[first_black:].count("#"))
    print(ans)

Submission status: Wrong Answer

Solution code:
SIRO = '.'
KURO = '#'
N = int(input())
S = input()
ans = 0
for i in range(0, N - 1):
    if S[i] == KURO:
        if S[i + 1] == SIRO:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

S = str(input())

target = S[0]
cnt = 0
for i in range(1, N):
    if target == '#' and S[i] == '#':
        cnt += 1
        continue
    if S[i] == '#':
        target = '#'

print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())  #数値入力
s=input()

print(min(s.count('.'), s.count('#')))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

add = 0
before = '.'
for i in S:
	if before == '#' and i == '.':
		add += 1
	before = i
	
print(add)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
c = 0
while S.count("#.") != 0:
  c += S.count("#.")
  S = S.replace("#.","##")
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l = [v+s[k+1] if k != len(s) - 1 else v for k, v in enumerate(s)]

print(l.count('#.'))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
S=input()

S2=list(S)
cnt1=0
for i in range(1, N):
    if S2[i-1]=='#' and S2[i]=='.':
        S2[i]='#'
        cnt1+=1

S3=list(S)
cnt2=0
for i in range(N-1, 0, -1):
    if S3[i-1]=='#' and S3[i]=='.':
        S3[i-1]='.'
        cnt2+=1

print(min(cnt1, cnt2))

Submission status: Wrong Answer

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

if S.find("#") != -1:
    print(S[S.find("#"):].count("."))
else:
    print(0)

Submission status: Wrong Answer

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

count = 0
for i in range(N-1):
  if S[i] == "#" and S[i+1] == ".":
    S[i+1] = "#"
    count += 1
    
print(count)

Submission status: Wrong Answer

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

white = 0
black = 0
for c in S:
    if c == ".":
        white += 1
    else:
        black += 1

print(min(white, black))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())
s.append("0")
ans=0
for i in range(n):
  if s[i]=="#" and s[i+1]==".":
    s[i+1] = "#"
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
t=s.find("#")
if t==-1:
    print(0)
else:
    print(min(s[t:].count("#"),s[t:].count(".")))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
left_w = n
for i in range(n):
    if s[i] == "#":
         left_w = i
         break
ans = 0
for i in range(n):
    if s[i] == ".":
        ans += 1
print(ans-left_w)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    S = list(input())

    count = 0
    for i in range(len(S) - 1):
        one = S[i]
        two = S[i+1]
        if (one == '#') and (two == '.'):
            count += 1
            S[i+1] = '#'

    print(count)





main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
l = -1
for i in range(n):
    if s[i:i+1] == "#":
        l = i
        break
if l == -1:
    print(0)
else:
    ans = 0
    for i in range(l,n):
        if s[i:i+1] == ".":
            ans += 1
    print(ans)

Submission status: Wrong Answer

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

res = 0
for i in range(len(S)-1):
    if S[i] == '#' and S[i+1] == '.':
        res += 1
    S[i+1] == '#'

print(res)

Submission status: Wrong Answer

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

count1 = s.count('.')
count2 = s.count('#')

print(min(count1, count2))

Submission status: Wrong Answer

Solution code:
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read() for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
S = read()[:-1]

for i, s in enumerate(S):
    if s == '#':
        S = S[i:]
        break
else:
    print(0)
    exit()

ans = 0
# tmp = ['#' for _ in range(N-i)]
for i, s in enumerate(S):
    if s == '.':
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
cnt = 0
judge = 0
for i in range(n):
    if s[i] == "#" and judge == 0:
        judge = 1
    elif judge == 1 and s[i] == ".":
        cnt += 1
print(cnt)

Submission status: Wrong Answer

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

#.#
tilnow = []
tilnow.append(S[0])
ans = 0

for i,s in enumerate(S[1:]):
    if s == ".":
        if tilnow[i-1] == "#":
            ans+=1
            tilnow.append("#")
        else:
            tilnow.append(".")
    else:
        tilnow.append("#")
print(ans)

Submission status: Wrong Answer

Solution code:
import math

#n=list(map(int,input().split()))
#x=int(input())
n=int(input())
s=input()
count=0
f=False
for a in range(len(s)):
    if f==True and s[a]==".":
        count+=1
    if s[a]=="#":
        f=True
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
b,w = 0,0

if '#' not in S:
    print(0)
else:
    for i in range(S.index('#'),N):
        if S[i] == '#':
            b += 1
        else:
            w += 1

    print(min(b,w))

Submission status: Wrong Answer

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

white, black = 0, 0

for i in range(n):
    if s[i] == "#":
        white = s[i:].count(".")
        break

for j in range(n):
    if s[(j+1)*(-1)] == ".":
        black = s[:(j+1)*(-1)].count("#")
        break

print(min(white, black))

Submission status: Wrong Answer

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

init_white=True
num_whites=0
num_blacks=0
tmp=0
for c in s:
    if init_white and c == ".":
        continue
    init_white = False

    if c == ".":
        num_whites += 1
        num_blacks += tmp
        tmp = 0
    
    if c == "#":
        tmp += 1

print(min(num_whites, num_blacks))

Submission status: Wrong Answer

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

prev = ''
count = 0
for c in S:
    if c == '.' and prev == '#':
        prev = '#'
        count += 1
        continue
    prev = c

print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
blackcnt = 0
whitecnt = 0
whiteflag = False

for i in range(N):
    if S[i] == '#':
        whiteflag = True
        blackcnt += 1
    elif whiteflag and S[i] == '.':
        whitecnt += 1

print(min(blackcnt, whitecnt) if whiteflag else 0)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
flag = False
res = 0
for i in range(N):
    if S[i] == '#':
        flag = True
    if S[i] == '.' and flag == True:
        res += 1
        flag = False
        
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def m():
    tmp = '.'
    ans = 0
    for c in S:
        if tmp == '#' and c == '.':
            ans += 1

        if c == '#':
            tmp = '#'
        else:
            tmp = '.'
    return ans

print(m())

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    if b < a:
        a,b = b,a
    if a <= c <= b:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    s = input()
    a = list(set(list(s)))
    k = II()
    for i in a:
        if s[k] != i:
            s = s.replace(i, "*")
    print(s)
    return

#C
def C():
    n = II()
    s = S()
    s.append(0)
    ans = 0
    for k in range(n):
        if s[k] == 0:
            break
        if s[k] == "#" and s[k + 1] == ".":
            ans += 1
    print(ans)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
s1 = '.' + (n - 1) * '#'
s2 = (n - 1) * '.' + '#'
s3 = n * '.'
s4 = n * '#'
p = [0, 0, 0, 0]
for i in range(n):
    if s[i] != s1[i]:
        p[0] += 1
    if s[i] != s2[i]:
        p[1] += 1
    if s[i] != s3[i]:
        p[2] += 1
    if s[i] != s4[i]:
        p[3] += 1
print(min(p))

Submission status: Wrong Answer

Solution code:
n = int(input())
listS=list(input())
count=0
index=0
bef=0
while index < len(listS):
    if index == 0:
        bef = listS[index]
    else:
        if bef == "#":
            if listS[index] == ".":
                count+=1
        bef = listS[index]
    index+=1
print(min(count, n-count))

Submission status: Wrong Answer

Solution code:
# coding:utf-8

def main():
    N = int(input())
    s = input()
    count1 = 0
    count2 = 0
    for i in s:
        if i != ".":
            count1 += 1
        if i != "#":
            count2 += 1

    print(min(count1,count2))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

count = 0

for i in range(1, N):
    if S[i] == '.' and S[i-1] == '#':
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
ans = 0
for i in range(len(S)):
    if i == len(S)-1:
        break
    s = S[i]
    n = S[i+1]
    if s=='#':
        if n=='.':
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())
print(min(s.count("#"),s.count(".")))

Submission status: Wrong Answer

Solution code:
n=int(input())
S=input()
sflag=0
a=0
b=0
for i in S:
    if i=="#" and sflag==0:
        sflag=1
    if sflag==1:
        if i==".":
            a+=1
        else:
            b+=1
print(min(a,b))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
L = []
for i in range(N):
  L.append(S[i])
L.reverse()
ans = 0
for i in range(N-1):
  P = L[i]
  Q = L[i+1]
  if P == '.':
    if Q == '#':
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(input().rstrip("#"))
if "#" not in S:
	print(0)
else:
	i=S.index("#")
	print(min(S[i:].count("#"), S[i:].count(".")))

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
s=input()
scnt=s.count('#')
if scnt>=math.ceil(n/2):
    print(n-scnt)
else:
    print(scnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())
c=0
for i in range(0,n-1,1):
    if s[i] == "#" and s[i+1] == ".":
        s[i] = "."
        c+=1
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
try:a=s[::-1].index("#")+1
except:a=0
count=0
for i in range(n-a):
    if s[i]==".":count+=1
print(n-a-count)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
t = S.count(".")
if t == N:
    print(0)
else:
    print(min(t,N-t))

Submission status: Wrong Answer

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

white = s.count('.')
black = s.count('#')

print(white if white <= black else black)

Submission status: Wrong Answer

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

ans = 0
for i in range(N-1):
    check1 = S[i]
    check2 = S[i+1]
#     print(check1,check2)
    if check1 == '#' and check2 == '.':
        ans += 1
print(ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(len(S)-1):
    if S[i] == '#' and S[i+1] == '.':
       ans += 1
print(ans)

Submission status: Wrong Answer

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