Problem:
 Score : 300 points    Problem Statement N tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N .  The i -th tile from the left is painted black if the i -th character of S is 0 , and painted white if that character is 1 .  You want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.  At least how many tiles need to be repainted to satisfy the condition?      Constraints  1 \leq |S| \leq 10^5  S_i is 0 or 1 .         Input Input is given from Standard Input in the following format:  S       Output Print the minimum number of tiles that need to be repainted to satisfy the condition.        Sample Input 1 000      Sample Output 1 1  The condition can be satisfied by repainting the middle tile white.       Sample Input 2 10010010      Sample Output 2 3       Sample Input 3 0      Sample Output 3 0

Solution (Python):
s = list(input())
cnt0 = 0
cnt1 = 0

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "1":
            cnt0 += 1
        else:
            cnt1 += 1
    else:
        if s[i] == "0":
            cnt0 += 1
        else:
            cnt1 += 1

print(min(cnt0, cnt1))

Solution (Python):
S = input()

first_zero_count=0
first_one_count=0

counter = '0'
for i in range (len(S)):
    if S[i] == counter:
        first_one_count += 1
    else:
        first_zero_count+=1
    if counter =='0':
        counter ='1'
    else:
        counter = '0'
    
print(min(first_one_count,first_zero_count))

Solution (Python):
S = [int(_) for _ in input()]

ptA = [_ % 2  for _ in range(len(S))]
ptB = [abs(_ - 1)  for _ in ptA]
cntA = 0
cntB = 0

for s, a, b in zip(S, ptA, ptB) :
    if s != a:
        cntA += 1

    if s != b:
        cntB += 1

ans = min(cntA, cntB)
print(ans)

Solution (Python):
s = list(map(int, input()))
cnt = 0

for i in range(1, len(s)):
	if s[i] == s[i-1]:
		cnt += 1
		if s[i] == 0:
			s[i] = 1
		else:
			s[i] = 0

print(cnt)

Solution (Python):
S=input()
count=0
for i in range(len(S)):
    """奇数番目を0,偶数番目を1にする"""
    if i%2==1:
        if S[i]=="1":
            count+=1
    else:
        if S[i]=="0":
            count+=1

if count<=len(S)/2:
    print(count)
else:
    print(len(S)-count)

Solution (Python):
s = [int(x) for x in list(input())]

n = len(s)

p = [s[i] == i % 2 for i in range(n)]
q = [s[i] == (i - 1) % 2 for i in range(n)]

result = min([sum(p), sum(q)])
print(result)

Solution (Python):
S=raw_input()
l=len(S)

p1=""
for i in range(l):
	p1+=str(i%2)

p2=""
for i in range(l):
	p2+=str( (i+1)%2 )

a1=0
for x,y in zip(S,p1):
	if x!=y:
		a1+=1

a2=0
for x,y in zip(S,p2):
	if x!=y:
		a2+=1

print min(a1,a2)

Solution (Python):


colors_1 = [int(x) for x in input()]
colors_2 = colors_1.copy()

count_1 = 0
count_2 = 0

for (i, c) in enumerate(colors_1):
    if i == 0:
        continue
    else:
        if colors_1[i-1] == c:
            colors_1[i] = int(not c)
            count_1 += 1

for (i, c) in enumerate(colors_2):
    if i == 0:
        colors_2[i] = int(not c)
        count_2 += 1
    else:
        if colors_2[i-1] == c:
            colors_2[i] = int(not c)
            count_2 += 1

print(min(count_1, count_2))

Solution (Python):



def solv(s):
    sum0 = 0
    sum1 = 0
    b = 0
    for a in s:
        if b == a:
            sum0 += 1
        else:
            sum1 += 1
        b = 1 - b

    ans = min(sum0, sum1)
    return ans


if __name__ == '__main__':

    s = map(int, input())
    ans = solv(s)
    print(ans)

Solution (Python):
S = input()

ans1, ans2 = 0, 0

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == '0':
            ans1 += 1
        else:
            ans2 += 1
    else:
        if S[i] == '1':
            ans1 += 1
        else:
            ans2 += 1

print(min(ans1, ans2))

Solution (Python):
s=input()
cnt=0

if s!='1': 
    for i in range(0,len(s),2):
        if s[i]=='0':
            cnt+=1
    for j in range(1,len(s),2):
        if s[j]=='1':
            cnt+=1
else:
    cnt=0

print(min(cnt,len(s)-cnt))

Solution (Python):
s = input()
odd = ''
even = ''
for i in range(len(s)):
    if i%2 == 0:
        odd = odd + s[i]
    else:
        even  = even + s[i]

odd_black_count = odd.count('0')
odd_white_count = odd.count('1')
even_black_count = even.count('0')
even_white_count = even.count('1')

print(min((odd_white_count + even_black_count),(odd_black_count + even_white_count)))

Solution (Python):
import sys
read = sys.stdin.readline

S = read()
len_s = len(S)-1


ans1 = 0  
for i, s in enumerate(S[:-1]):
    if i % 2:
        if s != '1':
            ans1 += 1
    else:
        if s != '0':
            ans1 += 1
    

print(min(ans1, (len_s-ans1)))

Solution (Python):
ls = []
s = input()
ls = list(s)
ans = 0
if len(s) == 1:
  print("0")
else:
  for i in range(len(ls)-1):
    if ls[i] == ls[i+1]:
      if ls[i] == '0':
        ls[i+1] = '1'
        ans = ans + 1
      else:
        ls[i+1] = '0'
        ans = ans + 1
    else:
      continue
  print(ans)

Solution (Python):
a=input()
n=len(a)
b=[]
for i in range(n):
    if i%2==0:
        b.append('0')
    else:
        b.append('1')
res=0
for i in range(n):
    if a[i]!=b[i]:
        res+=1
if res<n/2:
    print(res)
else:
    print(n-res)

Solution (Python):


import operator

def main():
    S = input()

    count0 = 0
    count1 = 0

    for i, char in enumerate(S):
        bit = i % 2
        count0 += int(char) ^ bit
        count1 += int(char) ^ (not bit) 

    
    print(min(count0, count1))


if __name__ == '__main__':
    main()

Solution (Python):
ss = input()

first_zero_count = 0
first_zero_last = '0'
first_one_count = 0
first_one_last = '1'
for s in ss:
    first_zero_count += 1 if s == first_zero_last else 0
    first_one_count += 1 if s == first_one_last else 0
    first_zero_last, first_one_last = first_one_last, first_zero_last
print(min(first_zero_count, first_one_count))

Solution (Python):
S = list(input())
ans = 0
for i in range(len(S)):
  if(i != 0):
    if(S[i] == S[i-1]):
      ans += 1
      if(S[i] == '0'):
        S[i] = '1'
      else: 
        S[i] = '0'
print(ans)

Solution (Python):
s = input()
tmp = "0"
A = 0
B = 0

for ss in s:
    if tmp != ss:
        A += 1
    if tmp == "1":
        tmp = "0"
    elif tmp == "0":
        tmp = "1"

tmp = "1"
for ss in s:
    if tmp != ss:
        B += 1
    if tmp == "1":
        tmp = "0"
    elif tmp == "0":
        tmp = "1"
if A < B:
    print(A)
else:
    print(B)

Solution (Python):
S = input()
a = 0
b = 0
for i in range(len(S)):
	if i % 2 == 0:
		if S[i] == '0':
			a += 1
		else:
			b += 1
	else:
		if S[i] == '0':
			b += 1
		else:
			a += 1
print(min(a, b))

Solution (Python):
import sys
input = sys.stdin.readline

S = input().rstrip()

if len(S) == 1:
    print(0)
else :
    S1 = S[0::2]
    S2 = S[1::2]

    p1 = len(S) - S1.count('1') - S2.count('0')
    p2 = len(S) - S1.count('0') - S2.count('1')

    if p1 > p2:
        print(p2)
    else:
        print(p1)

Solution (Python):
S = list(input())
 
res_10 = 0
res_01 = 0
 
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "0":
            res_10 += 1
        else:
            res_01 += 1
    else:
        if S[i] == "1":
            res_10 += 1
        else:
            res_01 += 1
print(min(res_10, res_01))

Solution (Python):
S=list(input())






N=len(S)

ans1=[]
ans2=[]

color=["0","1","0"]

for n in range(N):
	ans1.append(color[n%2])
	ans2.append(color[n%2+1])




diff1=0
diff2=0

for n in range(N):
	if S[n] != ans1[n]:
		diff1+=1
	if S[n] != ans2[n]:
		diff2+=1

print(min(diff1,diff2))

Solution (Python):
s = input()
n = len(s)
a = 0
b = 0
for i in range(0,n,2):
    if s[i:i+1] == "0":
        a += 1

for i in range(1,n,2):
    if s[i:i+1] == "1":
        b += 1

print(min(a + b,n - a - b))

Solution (Python):
s=input()
n=len(s)
a=""
b=""
for i in range(n):
  if i%2==1:
    a+="1"
  else:
    a+="0"
for i in range(n):
  if i%2==0:
    b+="1"
  else:
    b+="0"

cnt1=0
cnt2=0
for i in range(n):
  if s[i]==a[i]:
    cnt1+=1
  if s[i]==b[i]:
    cnt2+=1
print(min(cnt1,cnt2))

Solution (Python):
S = [int(i) for i in input()]


def count_reverse(t):
    count = 0
    for i, s_i in enumerate(S):
        if s_i != t:
            count += 1
        if t == 0:
            t = 1
        else:
            t = 0
    return count


c_0 = count_reverse(0)
c_1 = count_reverse(1)
print(min(c_0, c_1))

Solution (Python):


from sys import stdin
    
def calc(s):
    ans0 = 0
    ans1 = 0
    num = 0

    for x in s:
        if num == 0:
            if x == '0':
                ans1 += 1
            else:
                ans0 += 1
        else:
            if x == '1':
                ans1 += 1
            else:
                ans0 += 1
        num = (num + 1) % 2

    return min(ans0,ans1)

def main():
    s = stdin.readline().rstrip()
    ans = calc(s)
    print(ans)
    
if __name__=='__main__':
    main()

Solution (Python):
s=input()
n=len(s)
s1=''
s2=''
for i in range(n):
    if i%2==0:
        s1+='0'
        s2+='1'
    else:
        s1+='1'
        s2+='0'
dif1=sum(s1[i]!=s[i] for i in range(n))
dif2=sum(s2[i]!=s[i] for i in range(n))
print(min(dif1,dif2))

Solution (Python):
S = list(map(int, list(input())))
colors = [0, 1]
cnt_b, cnt_w = 0, 0
b_list = [colors[i % 2] for i in range(len(S))]

for i in range(len(S)):
    if S[i] == b_list[i]:
        cnt_w += 1
    else:
        cnt_b += 1
        
print(min([cnt_w, cnt_b]))

Solution (Python):
S = input()

ans1 = 0
for i in range(len(S)):
	if i%2==0:
		if S[i:i+1]=='1':
			ans1 += 1
	else:
		if S[i:i+1]=='0':
			ans1 += 1
ans2 = 0
for i in range(len(S)):
	if i%2==0:
		if S[i:i+1]=='0':
			ans2 += 1
	else:
		if S[i:i+1]=='1':
			ans2 += 1

print(min([ans1, ans2]))

Solution (Python):
s = input()
n = len(s)
cnt = 0
for i in range(n):
    if i%2==0:
        if s[i]=="0":
            cnt += 1
    else:
        if s[i]=="1":
            cnt += 1
print(min(cnt,n-cnt))

Solution (Python):
s = str(input())
S = [int(t) for t in s]
N=len(S)
S_1 = [i%2 for i in range(N)]
S_2 = [(i+1)%2 for i in range(N)]


n_1 =0
n_2 =0

for i in range(N):
    if S[i]!=S_1[i]:
        n_1 += 1
    else:
        n_2 += 1
    
ans = min(n_1,n_2)
print(ans)

Solution (Python):
def solve(s):
    return min(solve_partial(s), solve_partial(s[::-1]))


def solve_partial(s):
    n = len(s)
    cs = [int(c) for c in s]
    res = 0
    for i in range(n - 1):
        if cs[i] == cs[i + 1]:
            cs[i + 1] = int(not cs[i])
            res += 1
    return res


def main():
    s = input()
    res = solve(s)
    print(res)


if __name__ == "__main__":
    main()

Solution (Python):
ss = list(map(int, list(input())))


next=1
count1=0
for s in ss:
    if s != next:
        count1+=1
    next = (next+1)%2

next=0
count2=0
for s in ss:
    if s != next:
        count2+=1
    next = (next+1)%2

print(min(count1,count2))

Solution (Python):
s = input()
start = s[0]



ans1 = 0
for i, si in enumerate(s):
    if i % 2 == 0:
        if si != '0':
            ans1 += 1
    else:
        if si != '1':
            ans1 += 1


ans2 = 0
for i, si in enumerate(s):
    if i % 2 == 0:
        if si != '1':
            ans2 += 1
    else:
        if si != '0':
            ans2 += 1


ans = min(ans1, ans2)
print(ans)

Solution (Python):


N = input()
countA = 0
countB = 0
for n,i in enumerate(list(N)):
    if (n % 2 == 0 and i == "1") or (n % 2 == 1 and i == "0") :
        countA+=1
    if(n % 2 == 0 and i == "0") or (n % 2 == 1 and i == "1"):
        countB+=1

print(min(countB,countA))

Solution (Python):
s=input()

n=len(s)
n1=n//2
n2=n%2

if n2==0:
    k1="01"*n1
    k2="10"*n1
else:
    k1="01"*(n1)+"0"
    k2="10"*(n1)+"1"

count1=0
count2=0

for i in range(n):
    if k1[i]==s[i]:
        count1+=1
    if k2[i]==s[i]:
        count2+=1
        
print(min(count1,count2))

Solution (Python):
s=str(input())
n=len(s)

evensum = 0
oddsum = 0
evenall = 0
oddall = 0

for i in range(0,n,2):
    evensum += int(s[i])
    evenall += 1
for i in range(1,n,2):
    oddsum += int(s[i])
    oddall += 1


evendiff = evenall-evensum
odddiff = oddsum
even1count = evendiff+odddiff 


evendiff = evensum
odddiff = oddall-oddsum
odd1count = evendiff+odddiff 

print(min(even1count,odd1count))

Solution (Python):
s = input()

if len(s) % 2 == 0:
    a = '01' * (len(s) // 2)
    b = '10' * (len(s) // 2)
else:
    a = '01' * (len(s) // 2) + '0'
    b = '10' * (len(s) // 2) + '1'

s_i = int(s, 2)
a_i = int(a, 2)
b_i = int(b, 2)

s1 = bin(s_i ^ a_i)[2:]
s2 = bin(s_i ^ b_i)[2:]

print(min(s1.count('1'), s2.count('1')))

Solution (Python):
S = list(input())
answer = 0
first = True
flag = ""
for i in range(len(S)):
    if(first):
        first = False
        flag = S[i]
    else:
        if(flag == S[i]):
            answer += 1
            if(S[i] == "0"):
                S[i] = "1"
            else:
                S[i] = "0"
            flag = S[i]
        else:
            flag = S[i]
print(answer)

Solution (Python):
s = list(map(int,list(input())))



odd = 0
even = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == 0:
            even += 1
        if s[i] == 1:
            odd += 1
    else:
        if s[i] == 0:
            odd += 1
        if s[i] == 1:
            even += 1
    


print(min(odd,even))

Solution (Python):
S = str(input())
Sarray = list(S)
for i in range(len(Sarray)):
    Sarray[i] = int(Sarray[i])

count = [0] * 2
for i in range(2):
    if i == 1:
        if Sarray[0] == 1:
            Sarray[0] = 0
        else:
            Sarray[0] = 1
    
    for j in range(1,len(Sarray)):
        if Sarray[j] == Sarray[j-1]:
            count[i] += 1
            if Sarray[j] == 1:
                Sarray[j] = 0
            else:
                Sarray[j] = 1

count.sort

print(count[0])

Solution (Python):
S = input()

G0 = 0
K1 = 0

total = len(S)

g = False
for i in S:
    if i == "0" and g:
        G0 += 1
    if i == "1" and not g:
        K1 += 1
    g = not g

res = total - (G0 +  K1)
res = min(res, (G0 +  K1))       
print(res)

Solution (Python):
import numpy as np

a=input()
arr_a = np.array([int(x) for x in list(a)])
arr_1 = np.array([0 if i%2 == 0 else 1 for i in range(len(a))])
arr_2 = np.array([1 if i%2 == 0 else 0 for i in range(len(a))])

print(min(np.abs(arr_1 - arr_a).sum(), np.abs(arr_2 - arr_a).sum()))

Solution (Python):

s = str(input())

s = list(s)
s = list(map(lambda x: int(x), s))

count_odd = [0 for i in range(2)]
count_even = [0 for i in range(2)]

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == 0:
            count_even[0] += 1
        else:
            count_even[1] += 1
    else:
        if s[i] == 0:
            count_odd[0] += 1
        else:
            count_odd[1] += 1

ans = 0
if max(count_even) > max(count_odd):
    if count_even[0] >= count_even[1]:
        ans = count_even[1] + count_odd[0]
    else:
        ans = count_even[0] + count_odd[1]
else:
    if count_odd[0] >= count_odd[1]:
        ans = count_odd[1] + count_even[0]
    else:
        ans = count_odd[0] + count_even[1]
    
print(ans)

Solution (Python):
S=input()
od0=0
ev0=0
odn=len(S)//2
for i,ch in enumerate(S):
	if i%2==0:
		if ch=="0":
			ev0+=1
	else:
		if ch=="0":
			od0+=1
print(min(ev0+odn-od0,od0+len(S)-odn-ev0))

Solution (Python):
S = input()

def count(s1, s2):
  n = len(s1)
  count = 0
  for i in range(n):
    if s1[i] != s2[i]:
      count += 1
  return count

N = len(S)
S = list(S)

final_odd = ["0"] * N
final_even = ["0"] * N

for i in range(N):
  if i % 2 == 0:
    final_odd[i] = "1"
  else:
    final_even[i] = "1"
    
print(min(count(S, final_odd), count(S, final_even)))

Solution (Python):
S = input()
ans = [0, 0, 0, 0]

for i in range(len(S)):
    if (i % 2 == 0 and S[i] != '1') or (i % 2 == 1 and S[i] != '0'):
        ans[0] += 1
    if (i % 2 == 0 and S[i] != '0') or (i % 2 == 1 and S[i] != '1'):
        ans[1] += 1
    j = len(S) - i - 1
    if (j % 2 == 0 and S[j] != '1') or (j % 2 == 1 and S[j] != '0'):
        ans[2] += 1
    if (j % 2 == 0 and S[j] != '0') or (j % 2 == 1 and S[j] != '1'):
        ans[3] += 1
    
print(min(ans))

Solution (Python):
S = input()


I = ''
J = ''
for i in range(len(S)):
    if i % 2 == 0:
        I += '0'
        J += '1'
    else:
        I += '1'
        J += '0'

i_c = 0
j_c = 0
for s, i, j in zip(S, I, J):
    if s != i:
        i_c += 1
    if s != j:
        j_c += 1

print(min(i_c, j_c))

Solution (Python):
s = str(input())
s = list(s)
cnt = 0
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        cnt += 1
        if s[i] == "0":
            s[i+1] = "1"
        else:
            s[i+1] = "0"

print(cnt)

Solution (Python):
S = input()
L = len(S)

A = [ '0' if i%2 == 0 else '1' for i in range(L)]
ans = 0
for s, a in zip(S,A):
    if s == a: ans += 1
            
print(min(ans,L-ans))

Solution (Python):
S = input()

len_s = len(S)

import numpy as np
s_arr = np.array(list(map(int, list(S))))
s_arr[s_arr == 0] = -1

a_arr = np.ones(len_s)
a_arr[::2] = -1
b_arr = np.ones(len_s)
b_arr[1::2] = -1

num_a = sum((s_arr * a_arr) < 0)
num_b = sum((s_arr * b_arr) < 0)

print(min(num_a, num_b))

Solution (Python):
S = list(str(input()))
list = [int(s) for s in S]
cnta = 0
cntb = 0
for i, color in enumerate(list):
    if color == i % 2:
        cnta += 1
    else:
        cntb += 1
print(min(cnta, cntb))

Solution (Python):
S = str(input())

ans_one_start = ''
for i in range(len(S)):
    if i % 2 == 0:
        ans_one_start += '0'
    else:
        ans_one_start += '1'
        
ans_zero_start = ''
for i in range(len(S)):
    if i % 2 == 0:
        ans_zero_start += '1'
    else:
        ans_zero_start += '0'

diff_one = 0
diff_zero = 0

for i in range(len(S)):
    s_i = S[i]
    diff_i = ans_one_start[i]
    if s_i != diff_i:
        diff_one += 1
        
for i in range(len(S)):
    s_i = S[i]
    diff_i = ans_zero_start[i]
    if s_i != diff_i:
        diff_zero += 1
    
print(min(diff_one, diff_zero))

Solution (Python):
s = input()
ans1 = 0
ans2 = 0
for i in range(len(s)):
  if i % 2 == 0 and s[i] == "1":
    ans1 += 1
  elif i % 2 == 1 and s[i] == "0":
    ans1 += 1
for i in range(len(s)):
  if i % 2 == 0 and s[i] == "0":
    ans2 += 1
  elif i % 2 == 1 and s[i] == "1":
    ans2 += 1
print(min(ans1, ans2))

Solution (Python):
S = input()
even = 0
odd = 0
for i, s in enumerate(S):
    if (i + 1) % 2 == 0:
        even += int(s)
    else:
        odd += int(s)
N = len(S)
if even >= odd:
    ans = odd + N // 2 - even
else:
    if N % 2 == 0:
        ans = even + N // 2 - odd
    else:
        ans = even + N // 2 - odd + 1
print(ans)

Solution (Python):
inmap=input()

odd = {'0':0, '1':0}
ev = {'0':0, '1':0}
for i, tile in enumerate(inmap):
    if i % 2:
        odd[tile] += 1
    else:
        ev[tile] += 1

print(min( ev['0'] + odd['1'] , ev['1'] + odd['0'] ))

Solution (Python):
s = input()
s1 = s[::2]
s2 = s[1::2]
p1 = s1.count("1") + s2.count("0")
p2 = s1.count("0") + s2.count("1")
print(min(p1, p2))

Solution (Python):
S = [int(i) for i in input()]
s0 = [x for i,x in enumerate(S) if i % 2 == 0]
s1 = [x for i,x in enumerate(S) if i % 2 == 1]

num01 = sum(s0)
num11 = sum(s1)
print(min(num01+len(s1)-num11, num11+len(s0)-num01))

Solution (Python):
S = input()
cnt_1 = 0
cnt_2 = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "0":
            cnt_1 += 1
        else:
            cnt_2 += 1
    else:
        if S[i] == "1":
            cnt_1 += 1
        else:
            cnt_2 += 1
print(min(cnt_1, cnt_2))

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

S = input()


current = '0'
ans1 = 0
for s in S:
    if s == current:
        if current == '0':
            current = '1'
        else:
            current = '0'
    else:
        
        if current == '0':
            current = '1'
        else:
            current = '0'
        ans1 += 1

current = '1'
ans2 = 0

for s in S:
    if s == current:
        if current == '0':
            current = '1'
        else:
            current = '0'
    else:
        
        if current == '0':
            current = '1'
        else:
            current = '0'
        ans2 += 1

print(min(ans1, ans2))

Solution (Python):
s=input()
odd,even=s[1::2],s[0::2]
print(min(odd.count("1")+even.count("0"),odd.count("0")+even.count("1")))

Solution (Python):
S = list(input())

pat1 = 0
pat2 = 1
ans1 = 0
ans2 = 0

for s in S:

    if not s == str(pat1):
        ans1 += 1
    elif not s == str(pat2):
        ans2 += 1
    pat1 = abs(pat1-1)
    pat2 = abs(pat2-1)
print(min(ans1,ans2))

Solution (Python):
S=str(input())
s1=[0]
s2=[1]
for i in range(len(S)-1):
  if(s1[-1]==0): s1.append(1)
  else: s1.append(0)
for i in range(len(S)-1):
  if(s2[-1]==0): s2.append(1)
  else: s2.append(0)

d1=0
d2=0
for i,v in enumerate(S):
  d1 += abs(s1[i]-int(v))
  d2 += abs(s2[i]-int(v))

if(d1>d2): print(d2)
else: print(d1)

Solution (Python):
S = [int(i) for i in input()]

count = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 0:
            count += 1
    else:
        if S[i] == 1:
            count += 1

print(min(count,len(S)-count))

Solution (Python):
s = input()
k = s[0]
if(s[0]=='1'):
    for i in range(1,len(s)):
        if(i%2==1):
            k+='0'
        else:
            k+='1'
else:
    for i in range(1,len(s)):
        if(i%2==1):
            k+='1'
        else:
            k+='0'
u = 0
for i in range(len(k)):
    if(s[i]!=k[i]):
        u+=1
print(u)

Solution (Python):
s=input()
length=len(s)
s_list=[int(s[i]) for i in range(length)]
s_dimlist=[s[i+1]==s[i] for i in range(length-1)]

pre=0
isDone=True
cnt=0
for i in range(length-1):
    if s_dimlist[i]:
        if isDone:
            pre=i
            isDone=False
        else:
            cnt+=i-pre
            isDone=True
if not isDone:
    cnt+=length-1-pre
    
print(cnt)

Solution (Python):
s = input()
siro = 0
kuro = 0
for i in range(len(s)):
	if i%2 == 0:
		if s[i] == '0':
			kuro += 1
		if s[i] == '1':
			siro += 1
	if i%2 ==1:
		if s[i] == '0':
			siro += 1
		if s[i] == '1':
			kuro += 1
print(min(siro,kuro))

Solution (Python):
import numpy as np
H = np.array([int(i) for i in input()])
p1 = np.array([1 if i %2==0 else 0 for i in range(len(H)) ])
p2 = np.array([0 if i %2==0 else 1 for i in range(len(H)) ])
print(min([np.sum(H!=p1),np.sum(H!=p2)]))

Solution (Python):
l = list(input())
count = 0
currStr = ""
nextStr = ""
if len(l) >= 2:    
    for i in range(len(l)-1):
        currStr = l[i]
        nextStr = l[i+1]
        if currStr == nextStr:
            count += 1
            if nextStr == "1":
                l[i+1] = "0"
            else:
                l[i+1] = "1"

print(count)

Solution (Python):
s = input()
n = len(s)

candidate_1 = "10" * (n // 2) + "1" * (n % 2)
candidate_2 = "01" * (n // 2) + "0" * (n % 2)

cnt_1 = 0
cnt_2 = 0
for elem, can1, can2 in zip(s, candidate_1, candidate_2):
    if elem != can1:
        cnt_1 += 1
    if elem != can2:
        cnt_2 += 1
print(min(cnt_1, cnt_2))

Solution (Python):
from collections import Counter
S = input()
even = Counter(S[::2])
odd = Counter(S[1::2])
ans = min(even['0']+odd['1'], even['1']+odd['0'])
print(ans)

Solution (Python):
S = input()
A = ''.join([str(i % 2) for i in range(len(S))])
B = ''.join([str((i + 1) % 2)  for i in range(len(S))])

ans1 = ans2 = 0

for a, b in zip(S, A):
    if a != b:
        ans1 += 1

for a, b in zip(S, B):
    if a != b:
        ans2 += 1

print(min(ans1, ans2))

Solution (Python):
"""
map(int,input().split())

"""
S = input()

a = S[::2]
b = S[1::2]

a0 = 0
a1 = 0
b0 = 0
b1 = 0

for i in a:
    if i == '0':
        a0+=1
    else:
        a1+=1

for j in b:
    if j == '0':
        b0+=1
    else:
        b1+=1

r = min(a0,a1,b0,b1)

if r == a0:
    print(r+b1)
elif r == a1:
    print(r+b0)
elif r == b0:
    print(r+a1)
else:
    print(r+a0)

Solution (Python):
s = input()

ans = 0
for i in range(len(s)):
    if i % 2 == 0 and s[i] == '0':
        ans += 1
    elif i % 2 == 1 and s[i] == '1':
        ans += 1

print(ans if ans < len(s)-ans else len(s)-ans)

Solution (Python):
s=input()
ans1=0
ans2=0
for i in range(len(s)):
    if i%2==0:
        if s[i]=="0":
            ans1+=1
    else:
        if s[i]=="1":
            ans1+=1
for k in range(len(s)):
    if k%2==0:
        if s[k]=="1":
            ans2+=1
    else:
        if s[k]=="0":
            ans2+=1
print(min(ans1,ans2))

Solution (Python):
S = str(input())
S_len = len(S)

A = ('01' * 10**5)[:S_len]
B = ('10' * 10**5)[:S_len]


result_A = sum([a == s for a, s in zip(A, S)])
result_B = sum([b == s for b, s in zip(B, S)])
print(min([result_A, result_B]))

Solution (Python):

S = str(input())
s=len(S)
x=[0]*2
y=[0]*2

for i in range(s):
    if i%2==0 :
        if S[i]=="1":
            x[0]+=1
        else:
            x[1]+=1
    else:
        if S[i]=="1":
            y[0]+=1
        else:
            y[1]+=1
print(min(x[0]+y[1],x[1]+y[0]))

Solution (Python):
colors = input()

ans_1 = '01' * int(len(colors) / 2)
ans_2 = '10' * int(len(colors) / 2)
if len(colors) % 2 == 1:
    ans_1 = ans_1 + '0'
    ans_2 = ans_2 + '1'

replace_1 = 0
replace_2 = 0
for base, char_1, char_2 in zip(colors, ans_1, ans_2):
    if base != char_1:
        replace_1 += 1
    if base != char_2:
        replace_2 += 1
print(min(replace_1, replace_2))

Solution (Python):
import re
S = [int(item) for item in list(input())]


flip0 = sum(S[0::2]) + (len(S[1::2]) - sum(S[1::2]))


flip1 = sum(S[1::2]) + (len(S[0::2]) - sum(S[0::2]))

print(min(flip0, flip1))

Solution (Python):
s=(input())
ans=0
for i in range(len(s)):
    if(i%2==0 and s[i]=='1'):
        ans+=1
    if(i%2==1 and s[i]=='0'):
        ans+=1
print(min(ans,len(s)-ans))

Solution (Python):
S = str(input())
n = len(S)
ans1 = 0
ans2 = 0
for i in range(n):
    if i % 2 == 0:
        tmp1 = '1'
    else:
        tmp1 = '0'
    if S[i] != tmp1:
        ans1 += 1
    else:
        ans2 += 1
print(min(ans1, ans2))

Solution (Python):
S = input()

result = 0

t = S[0]
for s in S:
    if s != t:
        result +=1
    t = '1' if t == '0' else '0'

print(result)

Solution (Python):
s=list(str(raw_input()))

n=len(s)

if n%2==0:
	list1=[str(0),str(1)]*(n//2)
	list2=[str(1),str(0)]*(n//2)
else:
	list1=[str(0),str(1)]*(n//2)
	list1.append(str(0))
	list2=[str(1),str(0)]*(n//2)
	list2.append(str(1))

ctr1=0
ctr2=0

for i in range(n):
	if s[i]!=list1[i]:
		ctr1+=1
	if s[i]!=list2[i]:
		ctr2+=1

print min(ctr1,ctr2)

Solution (Python):
"""
python3 c.py < input.txt
"""
import math
import itertools as it
import heapq

S=input()
N=len(S)
a=0
for i in range(N):
    if i%2==0 and S[i] == "1":
        a=a+1
    elif i%2 ==1 and S[i]=="0":
        a=a+1

b=0
for i in range(N):
    if i%2==0 and S[i] == "0":
        b=b+1
    elif i%2 ==1 and S[i]=="1":
        b=b+1
print(min([a,b]))

Solution (Python):
from sys import stdin
N=(stdin.readline().rstrip())
A=0
B=0
for ind,i in enumerate(list(N)):
    if ind%2==0 and i != "0":
        A+=1
    elif ind%2!=0 and i != "1":
        A+=1

for ind,i in enumerate(list(N)):
    if ind%2==0 and i != "1":
        B+=1
    elif ind%2!=0 and i != "0":
        B+=1
print(min(A,B))

Solution (Python):
s = input()
s = list(s)


s = [int(x) for x in s]


leng = len(s)


count = 0
if s[0]==0:
    for i in range(leng):
        if i%2==1 and s[i]==0:
            count +=1
        elif i%2==0 and s[i]==1:
            count +=1
else:
    for i in range(leng):
        if i%2==1 and s[i]==1:
            count +=1
        elif i%2==0 and s[i]==0:
            count +=1

print(count)

Solution (Python):
s=input()
l=len(s)
word=''
for i in range(l):
    if i%2==0:
        word+='0'
    else:
        word+='1'
ans=0
for i in range(l):
    if s[i]!=word[i]:
        ans+=1
print(min(ans,l-ans))

Solution (Python):
s = input()
if len(s) == 0:
    print("0")
    exit()

s_10 = "10" * (len(s) // 2)
if len(s) % 2 != 0:
    s_10 += "1"

s_01 = "01" * (len(s) // 2)
if len(s) % 2 != 0:
    s_01 += "0"

a = len([i for i in range(len(s)) if s[i] != s_01[i]])
b = len([i for i in range(len(s)) if s[i] != s_10[i]])
ans = min(a, b)
print(ans)

Solution (Python):
s=input()
ls=len(s)
if ls%2:
    s1="10"*(ls//2)+"1"
    s2="01"*(ls//2)+"0"
else:
    s1="10"*(ls//2)
    s2="01"*(ls//2)
d=int(s,2)
d1=int(s1,2)
d2=int(s2,2)
h1=format(d^d1,"b").count("1")
h2=format(d^d2,"b").count("1")
print(min(h1,h2))

Solution (Python):
s = input()

ans1 = ""
ans2 = ""

for i in range(len(s)):
    if i%2 == 0:
        ans1 += "1"
        ans2 += "0"
    else:
        ans1 += "0"
        ans2 += "1"

ans11 = 0
ans22 = 0
for i in range(len(s)):
    if s[i:i+1] != ans1[i:i+1]:
        ans11 += 1
    if s[i:i+1] != ans2[i:i+1]:
        ans22 += 1
print(min(ans11,ans22))

Solution (Python):
s=input()
size=len(s)
even=s[0::2]
odd=s[1::2]
e_0=even.count("0")
e_1=even.count("1")
o_0=odd.count("0")
o_1=odd.count("1")
print(min(size-e_0-o_1,size-e_1-o_0))

Solution (Python):
s = input()
c = [int(s[i]) for i in range(len(s))]
count = 0
for i in range(1,len(s)):
  if c[i-1] == c[i]:
    if c[i] == 0:
      c[i] = 1
    else:
      c[i] = 0
    count += 1
print(count)

Solution (Python):
S = str(input())
check1 = 0
for i in range(len(S)):
    if i % 2 == 0 and S[i] != "0":

        check1 += 1
    if i % 2 != 0 and S[i] == "0":

        check1 += 1


check2 = 0
for i in range(len(S)):
    if i % 2 == 0 and S[i] != "1":

        check2 += 1
    if i % 2 != 0 and S[i] == "1":

        check2 += 1


print(min(check1,check2))

Solution (Python):
s=list(map(int,list(str(input()))))
l = len(s)
bs = [0 for i in range(l)]
ws = [0 for i in range(l)]
for i in range(l):
    if i%2==0:
        bs[i]=1
    else:
        ws[i]=1
b=0
w=0
for i in range(l):
    if s[i] != bs[i]:
        b += 1
    if s[i] != ws[i]:
        w += 1
print(min(b,w))

Solution (Python):
S = [int(x) for x in input()] 





odd =  [1 if i % 2 == 0 else 0 for i in range(len(S))]
even = [0 if i % 2 == 0 else 1 for i in range(len(S))]
print(min([
    sum(1 if i != j else 0 for i, j in zip(S, odd)),
    sum(1 if i != j else 0 for i, j in zip(S, even))
    ]))

Solution (Python):
def hanntenn(n):
    if n=="0":
        return "1"
    else:
        return "0"
    
s = input()
lists = list(s)
ans1 = 0
ans2 = 0
flag = "1"
for ob in lists:
    if ob == flag:
        flag = hanntenn(flag)
        continue
    else:
        flag = hanntenn(flag)
        ans1 += 1
flag = "0"
for ob in lists:
    if ob == flag:
        flag = hanntenn(flag)
        continue
    else:
        flag = hanntenn(flag)
        ans2 += 1
print(min(ans1,ans2))

Solution (Python):
s = input()

even = s[1::2]
odd = s[::2]
e1 = len(even) - even.count("1")
e0 = len(even) - even.count("0")
o1 = len(odd) - odd.count("1")
o0 = len(odd) - odd.count("0")


print(min(e1+o0, e0+o1))

Solution (Python):
S=input()
w=0
b=0
for i,s in enumerate(S):
  if i%2==0:
    if s=='0':
      w+=1
    else:
      b+=1
  else:
    if s=='0':
      b+=1
    else:
      w+=1
print(min(w,b))