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:
b = input()
a = list(str(input()))
counter = 0
if len(a) == 1:
    counter = 0
else:
    for i in range(0,len(a)-1):
        if a[i] == "#":
            if a[i] != a[i+1]:
                a[i+1] = '#'
                counter += 1
print(counter)

Submission status: Wrong Answer

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

if N == 1 :
    ans = 0
else :
    a = S.count(".")
    if "#" in S :
        ans = min(a, N-a)
    else :
        ans = 0
print(ans)

Submission status: Wrong Answer

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

count_1 = 0
count_2 = 0
for i in range(N-1):
  if S[i] == "#" and S[i+1] == ".":
    S[i+1] = "#"
    count_1 += 1
for i in range(N-1):
  if S[N - i - 1] == "." and S[N - i - 2] == "#":
    S[N - i - 1] = "#"
    count_2 += 1
    
print(min(count_1, count_2))

Submission status: Wrong Answer

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

black = 0
white = N

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

for i in range(N)[::-1]:
    if S[i] == ".":
        white = i
        break

cnt_white = S[black+1:].count(".")
cnt_black = S[:white].count("#")
ans = min(cnt_white,cnt_black)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
if s.count('#') == 0:
    print('0')
    exit()
num = s[s.find('#'):].count('.')
num = min(num,s.count('#'))
print(num)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    S = [str(i) for i in input()]

    black_num = 0
    white_num = 0

    for s in S:
        if s == "#":
            black_num += 1
        elif s == ".":
            white_num += 1

    if N != black_num + white_num:
        print("error")
        return

    print(min([black_num, white_num]))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
s=list(input())
ii = -1
count_a = 0
count_b = 1
for index, i in enumerate(s):
  if i == '#' and ii == -1:
    ii = index
    continue;
  elif ii == -1:
    continue;
  else:
    if i == '.':
      count_a+=1
    else:
      count_b+=1
      
print(min(count_a, count_b))

Submission status: Wrong Answer

Solution code:
import numpy as np

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


L = [0] * N
L1 = [0] * N
L2 = [0] * N
L3 = [0] * N
for i in range(N):
    L1[i] = 0
    L2[i] = 1
    L3[i] = 0
    if S[i] == ".":
        # white
        L[i] = 0
    else:
        L[i] = 1
L3[N-1] = 1

L = np.array(L)
L1 = np.array(L1)
L2 = np.array(L2)
L3 = np.array(L3)

a = [((L - L1)**2).sum(), ((L - L2)**2).sum(), ((L - L3)**2).sum()]
print(a)
ans = min(a)
print(ans)

Submission status: Wrong Answer

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

two_pre = ''
one_pre = ''
res = 0
for i in s:
    if two_pre == '.' and one_pre == '#' and i == '.':
        res += 1
        one_pre = i
        two_pre = '.'

    elif one_pre == '#' and i == '.':
        res += 1
        one_pre = '#'
        two_pre = one_pre
        
    else:
        two_pre = one_pre
        one_pre = i
        
print(res)

Submission status: Wrong Answer

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

print(min(s[s.find('#'):].count('#'),s[s.find('#'):].count('.')))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
cnt1 = 0
cnt2 = 0

for i in range(n):
    if s[i] == '#':
        cnt1 += 1
    else:
        cnt2 += 1
print(min(cnt1,cnt2))

Submission status: Wrong Answer

Solution code:
input()
S = input()

if '#' in S:
    black = S.index('#')
    print(min(S[black:].count('#'), S[black:].count('.')))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
li = []
for i in range(n):
    if s[i] == "#":
        li.append(i)
sum = 0
if len(li) == 0:
    print(0)
else:
    for i in range(len(li)-1):
        sum += li[i+1]-li[i]
    sum += len(s) - li[-1] -1
    print(sum)

Submission status: Wrong Answer

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

s = input()
S = list(s)

ans = 0
tmpW = 0
tmpB = 0
pre = -1

for s in S[::-1]:
    if s == '.' and pre == -1:
        tmpW += 1
        pre = 1
        # print("1")

    elif s == '.' and pre == 1:
        tmpW += 1
        # print("2")

    elif s == '.' and pre == 2:
        if tmpW < tmpB:
            ans += tmpW
        else:
            ans += tmpB
        pre == 1
        tmpW = 1
        tmpB = 0
        # print("3")

    if s == '#' and pre == 1:
        tmpB += 1
        pre = 2
        # print("4")

    elif s == '#' and pre == 2:
        tmpB += 1
        # print("5")

if tmpB == 0:
    pass
elif tmpW < tmpB:
    ans += tmpW
else:
    ans += tmpB
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

index = -1
flag = 0
for i, s in enumerate(S):
    if s == '.' and flag:
        idx = i - 1
        break
    if s == '#':
        flag = 1
        
if index < 0:
    print(0)
    sys.exit()

S = S[idx:]
num_black = S.count('#')
num_white = S.count('.')
print(min([num_black, num_white]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(S.find("#"),S.find("."))
if S.find("#") == -1 or S.find(".") == -1:
    print(0)

else:
    x = S[S.find("#"):].count(".")
    y = S[:(S.rfind(".")+1)].count("#")
    print(min(x,y))

Submission status: Wrong Answer

Solution code:
x = int(input());
s=list(input());

j = 0;

for i in range(len(s)):
    if str(s[i]) == '#':
        if i != len(s) - 1:
         if str(s[i+1]) == '.':
            j = j + 1;

print(j);

Submission status: Wrong Answer

Solution code:
"""
python3 a.py < input.txt
"""
import math
import itertools as it
import heapq
"""
N=int(input())
S=input()
K=int(input())

sk=S[K-1]
O=[]
for i in range(0,N):
    if S[i] == sk:
        O.append(S[i])
    else:
        O.append("*")

print("".join(O))
"""
N=int(input())
S=input()
lb=None
for i in range(N):
    if S[N-i-1] == "#":
        lb=N-i-1
nw=0
nb=0
if lb==None:
    print(0)
    exit()
for i in range(lb, N):
    if S[N-i-1] == "#":
        nb = nb+1
    if S[N-i-1] == ".":
        nw = nw+1

if lb != None:
    print(min(nb, nw))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
white = S.count(".")
if S[0] == "#":
    B = [1]*N
    W = [white]*N
else:
    B = [0]*N
    W = [white-1]*N
for i in range(1,N):
    if S[i] == "#":
        B[i] = B[i-1] + 1
        W[i] = W[i-1]
    else:
        B[i] = B[i-1]
        W[i] = W[i-1] - 1
print(B)
print(W)
Ans = [B[i]+W[i] for i in range(N)]
print(min(Ans))

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
c = 0
for i in range(0,n-1) :
    if s[i] == '#' and s[i] == s[i+1] :
        c += 0
    elif s[i] == '#' and s[i] != s[i+1] :
        c += 1
    else :
        c += 0
print(c)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
S = stdin.readline().rstrip()
count = 0
ans = S
for itr in range(0,N):
    # print(itr)
    if itr == N-1:
        continue
    if ans[itr] == '.' and ans[itr+1] == '#':
        count += 1
        ans = ans[:itr+1] + '.' + ans[itr+2:]
        # print(ans)
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("#")
k=0
for i in range(n):
    if s[-1-i]!="#":
        break
print(ans if ans < ans_1 else ans_1-i)

Submission status: Wrong Answer

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

count_1 = 0
count_2 = 0
for i in range(N-1):
  if S[i] == "#" and S[i+1] == ".":
    S[i+1] = "#"
    count_1 += 1
for i in range(N-1):
  if S[N - i - 1] == "." and S[N - i - 2] == "#":
    S[N - i] = "."
    count_2 += 1
    
print(min(count_1, count_2))

Submission status: Wrong Answer

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

sum = 0
sb = 0
sw = 0

for i in range(len(s)):
    if s[i] == '.':
        sw += 1
    else:
        sum += min(sb,sw)
        if (sb > sw):
            sb += sw + 1
            sw = 0
        else:
            sw = 0
            sb = 1

print(sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
t = S.count(".")
if t == N:
    print(0)
    exit(0)

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

print(min(S.count("#"),S[b:].count(".")))

Submission status: Wrong Answer

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

ans = 0
tmp = ""
for i in S:
    if tmp == "#" and i == ".":
        ans += 1
    tmp = i
    
print(ans)

Submission status: Wrong Answer

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

if "." not in s or "#" not in s:
    print(0)
    exit()

f = 0
res = 0
for i in s:
    if f == 1 and i==".":
        res += 1
    if i=="#":
        f = 1
else:
    print(min(res,abs(n-res)))

Submission status: Wrong Answer

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

lst = list(S)
count = 0

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

print(count)

Submission status: Wrong Answer

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

start = len(s)
i = 0
while(i<len(s)):
    if(s[i]=="#"):
        start = i
        i = len(s)
    else:
        i += 1

if(start == len(s)):
    print("0")
else:
    kuro = 1
    shiro = 0
    for i in range(len(s)-start-1):
        if(s[i+start+1]=="."):
            shiro += 1
        else:
            kuro += 1
    if(kuro<=shiro):
        print(kuro)
    else:
        print(shiro)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
ans = 0
black = False

if '#' in S:
    black = True

for i in range(N):
    if black == True and S[i] == '.':
        ans += 1

print(ans)

Submission status: Wrong Answer

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

WHITE = '.'
BLACK = '#'

ans = 0
w_num = 0
b_num = 0
only_w = True
is_w = True
for v in S:
    if only_w:
        if v == BLACK:
            only_w = False
            is_w = False
            b_num += 1
    else:
        if is_w:
            if v == WHITE:
                w_num += 1
            else:
                is_w = False
                ans += min(w_num, b_num)
                w_num = 0
                b_num = 1
        else:
            if v == BLACK:
                b_num += 1
            else:
                is_w = True
                w_num += 1

if is_w:
    ans += min(w_num, b_num)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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


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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
li = []
for i in range(n):
    if s[i] == "#":
        li.append(i)
sum = 0
if len(li) == 0:
    print(0)
else:
    for i in range(len(li)-1):
        sum = li[i+1]-li[i]
    sum += len(s) - li[-1] -1
    print(sum)

Submission status: Wrong Answer

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

cnt = 0
for s in S:
    if s == ".":
        cnt += 1
    else:
        break
ws = S[cnt:]
w = S.count(".")
bs = S[::-1]
cnt = 0
for s in bs:
    if s == ".":
        cnt += 1
    else:
        break
bs = bs[cnt:]
b = bs.count("#")
print(min(w, b))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
for i in range(n):
    if s[i]=="#":
      x=i
      break
b=s[i:].count("#") 
w=len(s[i:])-b
print(b if b<w else w)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
f = S.find('#')
black = S.count('#',f)
white = S.count('.')
if black < white:
    print(black)
else:
    print(white)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(input())
whites=[0]*N
curwhi=0
for k,i in enumerate(S):
    if i==".":
        curwhi+=1
        whites[k]=curwhi
curmin=1000000
allwhi=whites[N-1]
for k,w in enumerate(whites):
    curmin=min(curmin,k+1+allwhi-2*w)
print(curmin)

Submission status: Wrong Answer

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

trial_num = int(input())
stones = list(input())

turn_white_stones = 0
turn_black_stones = 0
count_start = False

for i in range(trial_num):
    if(count_start == False):
        if(stones[i] == "#"):
            count_start = True
    else:
        if(stones[i] == "."):
            turn_white_stones += 1

    if(stones[i] == "#"):
        turn_black_stones += 1

print(min(turn_black_stones, turn_white_stones))

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 = str(input())

cnt = 0
for i in S:
    if i == '#':
        cnt += 1
    else:
        break

ANS1 = S[cnt:].count('#') 

cnt = 0
for i in S:
    if i == '.':
        cnt += 1
    else:
        break

ANS2 = S[cnt:].count('.') 

print(min(ANS1, ANS2))

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


# globals
inf = float('inf')
N = 0
S = ""


def set_inputs():
    global N, S
    N = get_int()
    S = get_str()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    s = "".join(itertools.dropwhile(lambda c: c == ".", S))
    black = []
    white = []
    count = 0
    prev = "#"
    for c in s:
        if c == prev:
            count += 1
        else:
            if prev == "#":
                black.append(count)
            else:
                white.append(count)
            prev = c
            count = 1
    if prev == "#":
        black.append(count)
    else:
        white.append(count)
    ans = min(sum(black), sum(white))
    if len(black) == len(white) + 1:
        ans = min(sum(black[:-1]), sum(white))
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(str(input()))
sb = s.count("#")
sw = s.count(".")
if sb>sw:
  print(sw)
else:
  print(sb)

Submission status: Wrong Answer

Solution code:
N=int(input())
S = input()
left = -1
for i, s in enumerate(S):
    if s == '#':
        left = i
        break
if S[-1] == '#':
    t=len(S.split('.')[-1])
    print(min(S.count('#')-t, S[left:].count('.')))
else:
    print(min(S.count('#'), S[left:].count('.')))

Submission status: Wrong Answer

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

now = s[0]
count=0
for i in range(0,n-1):
    if now == "#" and s[i+1]==".":
        count+=1
        continue
    now = s[i+1]
print(count)

Submission status: Wrong Answer

Solution code:
def solve():
  N = int(input())
  S = input()
  foundBlack = False
  black, b, white = 0, 0, 0

  for stone in S:
    if stone == '#':
      if not foundBlack: foundBlack = True
      b = b + 1
    else:
      if not foundBlack: continue
      white = white + 1
      black = black + b
      b = 0
  return min(black, white)

print(solve())

Submission status: Wrong Answer

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

l = []
for i in S:
	if i == '#':
		l.append(0) #黒
	else:
		l.append(1) #白



ans = 0
for i in range(len(l)):
	if l[i:i+2] == [0, 1]:
		ans = ans + 1

print(ans)

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
        tmp = s
print(count)

Submission status: Wrong Answer

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

cand = [j for j in range(len(s)-1) if s[j] =="#" and s[j+1] !="#"]
count =0
if cand == []:
    print(0)
else:
    for i in cand:
        if s[i] == "#" and s[i+1] == ".":
            count +=1
    print(count)

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
count2=0
for a in range(len(s)-1):
    if s[a]=="#":
        count2+=1
print(min([count,count2]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
a = s.find("#")
anum = s.count("#")
b = s.find(".")
bnum = n - anum


print(min(s[a:].count("."),s[:b+2].count("#"),bnum,anum))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
while True:
    if len(s) == 0 or s[0] != ".":
        break
    if s[0] == ".":
        s.pop(0)
    else:
        break
while True:
    if len(s) == 0 or s[0] != "#":
        break
    if s[-1] == "#":
        s.pop(-1)
    else:
        break

a = s.count("#")
b = s.count(".")
print(min(a,b))

Submission status: Wrong Answer

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

if s == "." * n:
    print(0)
else:
    black = s.index("#")
    white = [i for i, x in enumerate(s[black:]) if x == "."]
    print(len(white))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
black = s.count('#')
if black > 0:
    del s[:s.index('#')]
    white = s.count('.')
    print(white)
else:
    print('0')

Submission status: Wrong Answer

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

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

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

print(min(res1,res2))

Submission status: Wrong Answer

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

count_1 = 0
count_2 = 0
for i in range(N-1):
  if S[i] == "#" and S[i+1] == ".":
    S[i+1] = "#"
    count_1 += 1
for i in range(N-1):
  if S[N - i - 1] == "." and S[N - i - 2] == "#":
    S[N - i] = "#"
    count_2 += 1
    
print(min(count_1, count_2))

Submission status: Wrong Answer

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

S = list(S)
ans = 0
for i in range(N):
    if i+1 < 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()
#All Black
allblack = S.count('.')
allwhite = S.count('#')
lastblack = S[:-2].count('#') + S[-1].count('.')
print(min(allblack, allwhite, lastblack))

Submission status: Wrong Answer

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

# input

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

w_n = S.count(".")
b_n = S.count("#")

if N==w_n or N==b_n:
    print(0)
    exit()

ans = 0
flg = False
for i in range(len(S)):
    if i == 0:
        continue
    if flg:
        a = "#"
        flg = False
    else:
        a = S[i-1]
    b = S[i]

    if a=="#" and b==".":
        flg = True
        ans +=1

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:
# -*- coding utf-8 -*-
N = int(input())
S = input()

ans = 0
frag = False
for s in S:
    if s == '#':
        frag = True
    if frag and s == '.':
        ans += 1
ans = min(ans, S.count('#'))
print(ans)

Submission status: Wrong Answer

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

# if (S not in "#"):
#     print("0")
#     exit()
count = 0
ans = 0
revcount = 0
Flag = False
for i in range(N-1,-1,-1):
    if S[i] == ".":
        Flag = True
        count+=1
    else:
        if Flag != False:
            revcount+=1
        ans+=count
        count=0
print(min(revcount,ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
counter = 0
S_list = []
for chara in S:
    S_list.append(chara)

for i in range(len(S_list)-1):
    if (S_list[i] == '#') and (S_list[i+1] == '.'):
        counter += 1 
        S_list[i+1] = '#'

print(counter)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input().split("#.")
print(len(S)-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
_min = float('inf')
for i in range(n+1):
    ss = '.'*i + '#' * (n-i)
    t = 0
    for j in range(n):
        if (s[j]) != ss[j]:
            t+=1
    if _min > t:
        _min = t
print(t)

Submission status: Wrong Answer

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

ans = 0
c = 0

for i in range(n):
    if s[i] == "#":
        c = 1
        break

if c == 0:
    print(0)

else:

    for i in range(n):

        if s[i] == "#":

            for j in range(n-i-1):
                
                if s[i+1+j] == ".":
                    ans += 1
            print(ans)
            break

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
def third_select(S):
    right = N - 1
    change = 0
    for i, s in enumerate(S[::-1]):
        if s == '#':
            right = N  - 1 - i
            break
        else:
            change += 1
    for s in S[:right]:
        if s == '#':
            change += 1
    return change

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

ALL_period = S.count('#')
ALL_sharp = N - ALL_period



print(min(ALL_period, ALL_sharp, third_select(S)))

Submission status: Wrong Answer

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

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

ans2 = 0
S2 = S[::-1]
for i in range(N):
    if S2[i] == '.':
        ans2 = S2[i:].count('#')
        break

print(min(ans1, ans2))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
z = 0
for i in s:
    if i == '#':
        break
    else:
        z += 1
a = s[z:].count(".")
b = s[z:].count("#")
print(min(a, b))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
if S.count('.') == N or S.count('#') == N:
    print(S[0] * N)
else:
    print(abs(S.count('.') - S.count('#')))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

finded_black = False
answer = 0

for c in s:
    if finded_black:
        if c == '#':
            continue
        else:
            answer += 1

    if not finded_black:
        if c == '.':
            continue
        else:
            finded_black = True

print(answer)

Submission status: Wrong Answer

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

counter=0
flag=0
for i in range(N):
    if flag ==0 and moji[i]=="#":
        flag=1
    elif flag==1 and moji[i]==".":
        counter+=1
        flag=0
print(counter)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
 
 
S2 = S.split("#")[1:]
if S2 == S:
        print("0")
else:
    sn = S2.count(".")
    sn2 = S.count("#")
    print(min(sn,sn2))

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(input())
flag=0
countB=0
for i in range(N):
  if S[i]=="#":
    if flag==0:
      Nint=i
      flag=1
    countB += 1
if flag==1:
  countW=N-Nint-countB
  if countB>countW:
    print(countW)
  else:
    print(countB)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
ans = 0
color = s[0]
if s[0] == ".":
    curw = 1
    curb = 0
else:
    curb = 1
    curw = 0
if color ==".":
    bool = 1
else:
    bool = 0
for i in range(1,n):
    if s[i] == color:
        if color == ".":
            curw +=1
        else:
            curb += 1
    elif i == n-1 and s[i] != color:
        ans += 1
    else:
        if bool %2 == 0:
            if s[i] == ".":
                curw +=1
            else:
                curb += 1
            color = s[i]
            bool +=1
        else:
            ans += min(curw,curb)
            curw = 0
            curb = 0
            if s[i] ==".":
                curw += 1
            else:
                curb += 1
            color = s[i]
            bool += 1

print(ans)

Submission status: Wrong Answer

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

res=0
for i in range(n-1):
	if sl[i]=="#" and sl[i+1]==".":
		res= res + 1
        
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
T = [0 if S[0] == "." else 1]
for s in S[1:]:
    T.append(T[-1] if s == "." else 1+T[-1])
sm = T[-1]
mini = 100000000000000
length = N
for t in T:
    length -= 1
    if mini > t+(length-(sm-t)):
        mini = t+(length-(sm-t))
print(mini)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
cnt = 0
for s in S:
    if s =='#':
        cnt += 1

if cnt:
    print(N-cnt)
else:
    print(0)

Submission status: Wrong Answer

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

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

print(ret)

Submission status: Wrong Answer

Solution code:
A = int(input())
B = input()
B += ' '
cnt = 0
for i in range(0,A):
  if B[i] == '#' and B[i+1] == '.':
    B = B.replace(B[i+1], '#', 1)
    cnt += 1
  
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
ans = S[0]
cnt = 0
for i in range(1, len(S)):
  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=input()
a=[]
for i in range(n):
    if i==0:
        if s[0]=="#":
            a.append(1)
        else:
            a.append(0)
    else:
        if s[i]=="#":
            a.append(a[i-1]+1)
        else:
            a.append(a[i-1])
min=n
for i in range(n):
    m=a[i]
    r=n-i-1-(a[n-1]-a[i])
    q=m+r
    if q<min:
        min=q
print(min)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = list(str(input()))

try:
    firstb = b.index('#')
except ValueError:
    firstb = len(b) + 1

numberb = b[firstb:].count('#')
if b[-1] == '#':
    numberb -= 1
numberw = b[firstb:].count('.')

if numberb < numberw:
    print(numberb)
else:
    print(numberw)

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
        target = '#'
        continue
    if S[i] == '#':
        target = '#'
    else:
        target = '.'

print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
a=0
b=0
p=0
for i in range(n):
    if s[i]=="#":
        p=1
        a+=1
    elif p==1:
        b+=1

print(min(a,b))

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] == "."):
		if(i >0 and s[i-1] != "#"):
			s[i] = "."
		else:
			s[i+1] = "#"
		ans += 1

print(ans)

Submission status: Wrong Answer

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

for n in range(N):
	if S[n:n+2] == "#." :
		M = n+1
		break

print( S[n + 1:].count("."))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy

n = int(input())
char = input()

char_list = numpy.array(list(char))

write = sum(char_list == ".")
black = sum(char_list == "#")

if char_list[-1] == "#":
    if write <= black - 1:
        print(write)
    else:
        print(black -1)
else:
    if write <= black:
        print(write)
    else:
        print(black)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

flag = 0
countWhite = 0 
for i in range(n):
  if ( s[i] == '#' ):
    flag = 1
  if ( flag == 1 and s[i] == '.' ):
    countWhite += 1

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

if (countWhite<countBlack) :
  ans = countWhite 
else :
  ans = countBlack 

print(ans)