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

pat0 = 0  
pat1 = 0  

for i, c in enumerate(S):
    if i % 2 == 0:
        if c == '0':
            pat0 += 1
        else:
            pat1 += 1
    else:
        if c == '0':
            pat1 += 1
        else:
            pat0 += 1

N = len(S)
print(min(N - pat0, N - pat1))

Solution (Python):
s = input()

ans = 10 ** 9
a = 0
for i, j in enumerate(s):
    if i % 2 != int(j):
        a += 1
ans = min(ans, a)

a = 0
for i, j in enumerate(s):
    if i % 2 == int(j):
        a += 1
ans = min(ans, a)

print(ans)

Solution (Python):
S = input()
N = len(S)
count_f1 = 0
count_f0 = 0

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

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

print(min(count_f1,count_f0))

Solution (Python):
s = input()
if len(s)%2 == 0:
    ans = "10"*(len(s)//2)
    ans2 = "01"*(len(s)//2)
    cnt = 0
    cnt2 = 0
    for i in range(len(s)):
        if ans[i] != s[i]:
            cnt+=1
        if ans2[i] != s[i]:
            cnt2+=1
else:
    ans = "10"*(len(s)//2)+"1"
    ans2 = "01"*(len(s)//2) + "0"
    cnt = 0
    cnt2 = 0
    for i in range(len(s)):
        if ans[i] != s[i]:
            cnt+=1
        if ans2[i] != s[i]:
            cnt2+=1
ans = min(cnt,cnt2)
print(ans)

Solution (Python):
s = input()
a = 0
b = 0
for i in range(len(s)):
    if i & 1:
        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):
s = list(input())
ans = 0
for i in range(1,len(s)):
    if s[i-1] == '1' and s[i] == '1':
        s[i] = '0'
        ans += 1
    elif s[i-1] == '0' and s[i] == '0':
        s[i] = '1'
        ans += 1
print(ans)

Solution (Python):
S = list(input())
pattern_1 = []
pattern_2 = []
cnt_1 = 0
cnt_2 = 0

for i in range(len(S)):
    if i % 2 == 0:
        pattern_1.append('1')
        pattern_2.append('0')
    else:
        pattern_1.append('0')
        pattern_2.append('1')

for (s, a, b) in zip(S, pattern_1, pattern_2):
    if s != a:
        cnt_1 += 1
    if s != b:
        cnt_2 += 1

print(min(cnt_1, cnt_2))

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

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

res1, res2 = len(s), len(s)
for i in range(len(s)):
    if i % 2 == 0:
        if int(s[i]) == 0:
            res1 -= 1
        if int(s[i]) == 1:
            res2 -= 1
    else:
        if int(s[i]) == 1:
            res1 -= 1
        if int(s[i]) == 0:
            res2 -= 1

ans = min(res1, res2)
print(ans)

Solution (Python):
import numpy as np
S = [int(s) for s in input()]
p1 = [1 if i % 2 == 0 else 0 for i in range(len(S))]
p2 = [0 if i % 2 == 0 else 1 for i in range(len(S))]
print(min(np.count_nonzero(np.logical_xor(p1, S)), np.count_nonzero(np.logical_xor(p2, S))))

Solution (Python):
s = input()

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

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

print(min(ans1, ans2))

Solution (Python):
n = input()
list_n = list(n)
c = len(list_n)
ans_a = 0
ans_b = 0

for i in range(c):
    if i % 2 == 0:
        if list_n[i] == "0":
            ans_a += 1
    if i % 2 == 1:
        if list_n[i] == "1":
            ans_a += 1

for i in range(c):
    if i % 2 == 0:
        if list_n[i] == "1":
            ans_b += 1
    if i % 2 == 1:
        if list_n[i] == "0":
            ans_b += 1

print(min(ans_a, ans_b))

Solution (Python):
S = list(input())
count = 0
for i in range(0,len(S)-1):
    if S[i]==S[i+1]:
        count+=1
        if S[i]=="0":
            S[i+1]="1"
        else:
            S[i+1]="0"
print(count)

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

arr = list(map(int, s))

ref1 = [0] * len(s)
for i in range(len(ref1)):
    if i % 2 == 0:
        ref1[i] = 1

ref2 = [0] * len(s)
for i in range(len(ref2)):
    if i % 2 == 1:
        ref2[i] = 1

score1 = 0
for i in range(len(s)):
    if ref1[i] != arr[i]:
        score1 += 1


score2 = 0
for i in range(len(s)):
    if ref2[i] != arr[i]:
        score2 += 1
    
print(min(score1,score2))

Solution (Python):
S = list(map(int, list(input())))
L = len(S)

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

print(min(count, L-count))

Solution (Python):




def main():

    S = input()

    n = len(S)
    a = "10" * (n // 2) + "1" * (n % 2)
    b = "01" * (n // 2) + "0" * (n % 2)

    result = min(bin(int(S, 2) ^ int(a, 2)).count("1"),
                 bin(int(S, 2) ^ int(b, 2)).count("1"))

    print(result)


if __name__ == "__main__":
    main()

Solution (Python):




def main():
    S = list(map(int, list(input())))

    result = 0
    for i in range(1, len(S)):

        if S[i - 1] == S[i]:
            if S[i] == 1:
                S[i] = 0
            else:
                S[i] = 1
            result += 1

    print(result)


if __name__ == "__main__":
    main()

Solution (Python):
S = input()

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

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

print(min(cnt1, cnt2))

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:
            ans2 += 1
    if i % 2 == 1:
        if s[i] == '0':
            ans2 += 1
        else:
            ans1 += 1
print(min(ans1, ans2))

Solution (Python):
S = input()
e_cnt, o_cnt = 0, 0
for i in range(len(S)):
  if S[i] != str(i % 2):
    e_cnt += 1
  elif S[i] != str((i+1) % 2):
    o_cnt += 1
print(min(e_cnt, o_cnt))

Solution (Python):
S=input()

A="01"*(len(S)//2)+"0"*(len(S)%2)
count_A=0

B="10"*(len(S)//2)+"1"*(len(S)%2)
count_B=0

for i in range(len(S)):
    if S[i]!=A[i]:
        count_A+=1
    if S[i]!=B[i]:
        count_B+=1

print(min(count_A,count_B))

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

Solution (Python):
from fractions import gcd

S = input()
odd = [0,0]
even = [0,0]
for i,s in enumerate(S):
  if i % 2 == 0:
    even[int(s)]+=1
  else:
    odd[int(s)]+=1
o0e1 = odd[1]+even[0]
o1e0 = odd[0]+even[1]
print(min(o0e1,o1e0))

Solution (Python):

s = input()

ans1 = 0
ans2 = 0

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

print(min(ans1, ans2))

Solution (Python):
s = input()

cnt = 0
for i in range(len(s)):
    if i%2 != int(s[i]):
        cnt += 1
print(min(cnt, len(s)-cnt))

Solution (Python):
s=input()
t='01'*(len(s))
d1=0

d2=0

for i in range(len(s)):
    if s[i]!=t[i]:
        d1+=1
    if s[i]!=t[i+1]:
        d2+=1
print(min(d1,d2))

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

Solution (Python):
S = input()

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

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

print(min(ans1,ans2))

Solution (Python):
S = input()
l = len(S)
tmp0 = ''
tmp1 = ''
for i in range(l):
    if i&1:
        tmp0 += '0'
        tmp1 += '1'
    else:
        tmp0 += '1'
        tmp1 += '0'

cnt0 = 0
cnt1 = 0
for i in range(l):
    if S[i]==tmp0[i]:
        cnt0 += 1
    if S[i]==tmp1[i]:
        cnt1 += 1
print(min(cnt0,cnt1))

Solution (Python):
def main():
  s=list(input())
  count1,count2,l=0,0,len(s)
  for i in range(l):
    count1=count1+1 if (i%2==0 and int(s[i])==1) or (i%2==1 and int(s[i])==0) else count1
    count2=count2+1 if (i%2==1 and int(s[i])==1) or (i%2==0 and int(s[i])==0) else count2
  print(min(count1,count2))

if __name__=='__main__':
  main()

Solution (Python):

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

Solution (Python):

n=input()
def check(n,st_num):
    count=0
    dic={1:1,0:2}
    for i in range(1,-(-len(n)//2)):
        try:
            if n[2*i]+n[2*i+1]==st_num:
                count+=0
            else:
                count+=dic[abs(int(n[2*i])+int(n[2*i+1])-1)]
        except:
            if n[2*i]!=st_num[0]:
                count+=1
    
    return count
    
if '1' not in n:
    print(len(n)//2)
    exit()
if n[:2]=="10":
    print(check(n,"10"))
elif n[:2]=="01":
    print(check(n,"01"))
else:
    print(0 if len(n)==1 else min([check(n,"10")+1,check(n,"01")+1]))

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

def change():
    global kk
    if kk == "1":
        kk = "0"
    else:
        kk = "1"


count_1 = 0
kk = "1"
for c in range(L):
    if kk == S[c]:
        pass
    else:
        count_1 += 1
    change()
    


count_2 = 0
kk = "0"
for c in range(L):
    if kk == S[c]:
        pass
    else:
        count_2 += 1
    change()

if count_1 < count_2:
    print(count_1)
else:
    print(count_2)

Solution (Python):
import sys
from bisect import bisect_left,bisect_right,insort


def main():
    s=list(input())
    a,b=0,0
    x,y=0,0
    for i in range(len(s)):
        if i%2==0:
            a+=int(s[i])
            x+=1
        else:
            b+=int(s[i])
            y+=1
    print(min(x-a+b,y-b+a))
           

if __name__ == '__main__':
    main()

Solution (Python):
s=list(input())
cnt=0
for i in range(1,len(s)):
  if s[i]==s[i-1]=='1':
    cnt+=1
    s[i]='0'
  elif s[i]==s[i-1]=='0':
    cnt+=1
    s[i]='1'
print(cnt)

Solution (Python):
s = input()
s_ls = [i for i in s]
count = 0
for i in range(len(s)-1):

    if s_ls[i] == s_ls[i+1]:
        count += 1
        if s_ls[i+1] == '1':
            s_ls[i+1] = '0'
        else:
            s_ls[i+1] = '1'
print(count)

Solution (Python):





s=list(input())
n=len(s)


goal1=["1" if i%2==0 else "0" for i in range(n)]
count1=0

goal2=["0" if i%2==0 else "1" for i in range(n)]
count2=0
for i in range(n):
    if goal1[i]!=s[i]:
        count1+=1
    if goal2[i]!=s[i]:
        count2+=1

print(min(count1,count2))

Solution (Python):


start_col = ["0", "1"]

s = input().rstrip()


def get_next(prev: str):
    if prev == "0":
        return "1"
    else:
        return "0"


ans = len(s)
for i in start_col:
    current = i
    cnt = 0
    for j in range(len(s)):
        if s[j] != current:
            cnt += 1
        current = get_next(current)
    ans = min(ans, cnt)

print(ans)

Solution (Python):
S = input()
res1 = res2 = 0
for i in range(len(S)):
    if (i%2 == 0 and S[i] == '0') or (i%2 == 1 and S[i] == '1'):
        res1 += 1
    if (i%2 == 0 and S[i] == '1') or (i%2 == 1 and S[i] == '0'):
        res2 += 1
print(min(res1, res2))

Solution (Python):
S = input()

n = len(S)
cnt = 0

for i in range(n):
  if int(S[i])%2 == i%2:
    cnt += 1
    
print(min(cnt, n-cnt))

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

print(min(ans,ans1))

Solution (Python):
s = input()

alt_01 = int('01' * (len(s)//2) + '0' * (len(s)%2), 2)
alt_10 = int('10' * (len(s)//2) + '1' * (len(s)%2), 2)

bin_s = int(s, 2)
xor_01 = bin_s ^ alt_01
xor_10 = bin_s ^ alt_10

print(min(format(xor_01, 'b').count('1'), format(xor_10, 'b').count('1')))

Solution (Python):


s = input().rstrip()

default = ["0", "1"]

ans = len(s)
for i in default:
    current = i
    cnt = 0
    for j in s:
        if j == current:
            cnt += 1
        if current == "1":
            current = "0"
        else:
            current = "1"
    ans = min(ans, cnt)

print(ans)

Solution (Python):



def main():
  s = list(map(int, list(input().strip())))
  odd1, odd0, even1, even0 = 0, 0, 0, 0
  for i in range(len(s)):
    if i%2 == 0:
      if s[i] == 0:
        even0 += 1
      else: 
        even1 += 1
    else:
      if s[i] == 0:
        odd0 += 1
      else:
        odd1 += 1
  print(min(even0+odd1, even1+odd0))

if __name__=='__main__':
  main()

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

diff0, diff1 = 0, 0
for i, s in enumerate(S):
  if i%2 == 0:
    if s == '0':
      diff1 += 1
    else:
      diff0 += 1
  else:
    if s == '0':
      diff0 += 1
    else:
      diff1 += 1

ans = min(diff0, diff1)
print(ans)

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

ans = even.count('0') + odd.count('1')
if ans > even.count('1') + odd.count('0'):
    ans = even.count('1') + odd.count('0')

print(ans)

Solution (Python):
s=list(input())
import copy
d=copy.copy(s)
x=0
y=1
for i in range(len(s)-1):
  if s[i]==s[i+1]:
    if s[i+1]=='1':
       s[i+1]='0'
    else:s[i+1]='1'
    x+=1
if d[0]=='1':
  d[0]='0'
else:d[0]='1'
for i in range(len(d)-1):
  if int(d[i])==int(d[i+1]):
    if d[i+1]=='1':
      d[i+1]='0'
    else:d[i+1]='1'
    y+=1
print(min(x,y))

Solution (Python):





import sys
from collections import deque

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    s = input()
    l = len(s)
    odd = 0
    even =0

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

    
    a = (l // 2) - even + odd

    
    b = ((l+1) // 2) - odd + even

    print(min(a,b))


if __name__ == '__main__':
    main()

Solution (Python):
s = input()


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


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

print(min(countA,countB))

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

Solution (Python):
s = input()

if s[0] == '0':
  even = '0'
  odd = '1'
else:
  even = '1'
  odd = '0'

cnt = 0
for i in range(len(s)):
  if (i%2 == 0 and s[i]!= even) or (i%2 == 1 and s[i]!= odd):
    cnt += 1
print(cnt)

Solution (Python):
def main():
    S = input()
    N = len(S)

    full_even = (N + 1) // 2
    even = 0
    for i in range(0, N, 2):
        if S[i] == '0':
            even += 1

    full_odd = N // 2
    odd = 0
    for i in range(1, N, 2):
        if S[i] == '0':
            odd += 1

    
    case1 = even + full_odd - odd
    case2 = odd + full_even - even
    print(min(case1, case2))


if __name__ == "__main__":
    main()

Solution (Python):


s = input().strip()


flag=0
ans=[]
for flag in [0,1]:
    
    calc=0
    for i in range(len(s)):
        if s[i] != str( (i%2 == flag)*1 ):
            calc += 1

    ans += [calc]
    
print(min(ans))

Solution (Python):
s=input();t=s[0::2].count('0')+s[1::2].count('1');print(min(t,len(s)-t))

Solution (Python):
s=input();t=s[::2].count('0')+s[1::2].count('1');print(min(t,len(s)-t))

Solution (Python):
s = input()
sa = s[::2]
sb = s[1::2]

sa1, sb1 = sa.count('0'), sb.count('1')
ty1 = sa1 + sb1
ty2 = len(s) - sa1 - sb1
if ty1 > ty2:
  print(ty2)
else:
  print(ty1)

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

ans = 0

for i in range(len(S)-1):
    if S[i] == S[i+1]:

        ans += 1

        if S[i+1] == "1":
            S[i+1] = "0"

        else:
            S[i+1] = "1"

print(ans)

Solution (Python):
S=input()
count10=0
count01=0
def c10(s,n,count10):
    if ((n%2==0)and(s=="1"))or((n%2==1)and(s=="0")):
        count10=count10+1
    return count10
def c01(s,n,count01):
    if ((n%2==0)and(s=="0"))or((n%2==1)and(s=="1")):
        count01=count01+1
    return count01

for i in range(len(S)):
    count10=c10(S[i],i,count10)
    count01=c01(S[i],i,count01)
print(min(len(S)-count10,len(S)-count01))

Solution (Python):
import sys
S = input()
S_list = list(S)

l = len(S)


if len(S) % 2 == 0:
  ideal1 = list('01' * int(l / 2))
  ideal2 = list('10' * int(l / 2))
else:
  ideal1 = list('01' * (l // 2) + '0')
  ideal2 = list('10' * (l // 2) + '1')

ans = 0
ans1 = 0

for base,compe1 in zip(S_list,ideal1):
    if base != compe1:
        ans = ans + 1

for base,compe2 in zip(S_list,ideal2):
    if base != compe2:
        ans1 = ans1 + 1

print(min(ans,ans1))

Solution (Python):
S = input()

dif1 = 0
dif2 = 0

for i in range(len(S)):
	if i%2 == 0 and S[i] == '0':
		dif1 += 1
	if i%2 == 1 and S[i] == '1':
		dif1 += 1
	if i%2 == 0 and S[i] == '1':
		dif2 += 1
	if i%2 == 1 and S[i] == '0':
		dif2 += 1

print(min([dif1, dif2]))

Solution (Python):
S=input()
c=S[::2].count('0')+S[1::2].count('1')
print(min(c,len(S)-c))

Solution (Python):
S = input()
white_cnt = black_cnt = 0
ans = 0
for i in range(len(S)):
    if S[i]=="0":
        black_cnt += 1
        white_cnt = 0
    else:
        white_cnt += 1
        black_cnt = 0
    if black_cnt==2:
        ans += 1
        black_cnt = 0
        white_cnt += 1
    elif white_cnt == 2:
        ans += 1
        white_cnt = 0
        black_cnt += 1
print(ans)

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

Solution (Python):
S = input()

start1 = []
start0 = []

ans1 = 0
ans0 = 0

for i in range(len(S)):
    if i%2 == 0:
        start1.append('1')
        start0.append('0')
    else:
        start1.append('0')
        start0.append('1')
        
for i in range(len(S)):
    if S[i] != start1[i]:
        ans1 +=1
    
    if S[i] != start0[i]:
        ans0 +=1
        
print(min(ans1,ans0))

Solution (Python):

S=input()
def Count(S,x):
    res=0
    for i in range(len(S)):
        if i%2==x:
            if S[i]=='0':
                res+=1
        else:
            if S[i]=='1':
                res+=1
    return res

print(min(Count(S,0),Count(S,1)))

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

pre_c = None
l_count = 0
for c in s:
  if c == pre_c:
    l_count += 1
    pre_c = '0' if c == '1' else '1'
  else:
    pre_c = c

pre_c = None
r_count = 0
s.reverse()
for c in s:
  if c == pre_c:
    r_count += 1
    pre_c = '0' if c == '1' else '1'
  else:
    pre_c = c
print(min(l_count, r_count))

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

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

Solution (Python):
s = input()

a = 0
b = 1
ans_a = 0
ans_b = 0

for i in range(len(s)):
    if int(s[i]) != a:
        ans_a += 1
    else:
        ans_b += 1
    if a == 0:
        a = 1
        b = 0
    else:
        a = 0
        b = 1

print(min(ans_a, ans_b))

Solution (Python):
S = input()
a = 0
b = 0

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

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

print(ans)

Solution (Python):
s=input()
n=len(s)
a=["1"]*n
b=["0"]*n
for i in range(1,n):
    if a[i-1]=="1":
        a[i]="0"
    else:
        a[i]="1"
for i in range(1,n):
    if b[i-1]=="1":
        b[i]="0"
    else:
        b[i]="1"
cnt=0
for i in range(n):
    if a[i]!=s[i]:
        cnt+=1
ans=cnt
cnt=0
for i in range(n):
    if b[i]!=s[i]:
        cnt+=1
ans=min(ans,cnt)
print(ans)

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

fcount0 = 0
fcount1 = 0

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

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

print(min(fcount0, fcount1))

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

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

def count1(str):
    count = 0
    for i in range(len(str)):
        x = str[i]
        if i%2==0:
            if x!='0':
                count += 1
        else:
            if x!='1':
                count += 1

    return count

def count2(str):
    count = 0
    for i in range(len(str)):
        x = str[i]
        if i%2==0:
            if x!='1':
                count += 1
        else:
            if x!='0':
                count += 1

    return count

answer = min(count1(s),count2(s))
print(answer)

Solution (Python):
import sys
s=sys.stdin.buffer.readline().rstrip()
n=len(s)
a=0
for i in range(n):
    a+=s[i]%2==i%2
print(min(a,n-a))

Solution (Python):
S = input()
ans = []
if len(S) % 2 == 0:
    k = 0
    for i in range(len(S)//2):
        if S[2*i] != '0':
            k += 1
        if S[2*i + 1] != '1':
            k += 1
    ans.append(k)
    l = 0
    for i in range(len(S)//2):
        if S[2*i] != '1':
            l += 1
        if S[2*i + 1] != '0':
            l += 1
    ans.append(l)
    print(min(ans))
elif len(S) > 1 and len(S) % 2 != 0:
    k = 0
    for i in range(len(S)//2):
        if S[2*i] != '0':
            k += 1
        if S[2*i + 1] != '1':
            k += 1
    if S[-1] != '0':
        k += 1
    ans.append(k)
    l = 0
    for i in range(len(S)//2):
        if S[2*i] != '1':
            l += 1
        if S[2*i + 1] != '0':
            l += 1
    if S[-1] != '1':
        l += 1
    ans.append(l)
    print(min(ans))
else:
    print(0)

Solution (Python):
S = input()
a = "".join(["0" if i%2 else "1" for i in range(len(S))])
b = "".join(["0" if i%2==0 else "1" for i in range(len(S))])
ans1 = 0
ans2 = 0
for i in range(len(S)):
    if a[i] != S[i]:
        ans1 += 1
    if b[i] != S[i]:
        ans2 += 1
print(min(ans1,ans2))

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

Solution (Python):
s=input()
s=list(map(int,s))
a=[0]*len(s)
b=[0]*len(s)
for i in range(0,len(s),2):
    a[i]=1
for i in range(1,len(s),2):
    b[i]=1
cnt1=0
cnt2=0

for i,j in zip(a,s):
    if i!=j:
        cnt1+=1
for i,j in zip(b,s):
    if i!=j:
        cnt2+=1 
print(min([cnt1,cnt2]))

Solution (Python):
s=list(map(int,list(input())))
ans=0
t=s[0]
for u in s[1:]:
  if u==t:
    ans+=1
    t= int(not bool(u))
  else:
    t=u
print(ans)

Solution (Python):
s=input()
c1=0
c2=0
for i in range(len(s)):
    if i%2==0:
        if s[i]!="0":
            c1+=1
    else:
        if s[i]!="1":
            c1+=1
for i in range(len(s)):
    if i%2==0:
        if s[i]!="1":
            c2+=1
    else:
        if s[i]!="0":
            c2+=1

print(min(c1,c2))

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

patternA = []
patternB = []
countA = 0
countB = 0

for x in range(lenS):
    if x % 2 == 0:
        if S[x] == "0":
            countA += 1
        else:
            countB += 1
    else:
        if S[x] == "1":
            countA += 1
        else:
            countB += 1

if countA < countB:
    print(countA)
else:
    print(countB)

Solution (Python):
import sys

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import heapq
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15

def main():
    s = input().strip()
    ans, ans2 = 0, 0
    tmp = 0
    for c in s:
        if c != str(tmp):
            ans += 1
        tmp = 1 - tmp
    tmp = 1
    for c in s:
        
        if c != str(tmp):
            ans2 += 1
        tmp = 1 - tmp

    print(min(ans, ans2))
if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





s=list(ss())
lens=len(s)
cnt_odd=0
cnt_even=0
for i in range(lens):
    if i%2==0:
        if s[i]=="0":
            cnt_even+=1
        else:
            cnt_odd+=1
    else:
        if s[i]=="0":
            cnt_odd+=1
        else:
            cnt_even+=1
print(min(lens-cnt_even,lens-cnt_odd))

Solution (Python):
s = input()
s_lis = list(s)
l = len(s)
a = ['0' if i%2 == 0 else '1' for i in range(l)]
b = ['1' if i%2 == 0 else '0' for i in range(l)]
a_count = 0
b_count = 0
for si,ai,bi in zip(s_lis,a,b):
    if si != ai:
        a_count += 1
    if si != bi:
        b_count += 1
print(min(a_count,b_count))

Solution (Python):
S = input()
s = ''
s2 = ''
for i in range(len(S)):
    s += str(i % 2)
    s2 += str((i+1) % 2)
c = 0
c2 = 0
for i in range(len(S)):
    if S[i] != s[i]:
        c += 1
    if S[i] != s2[i]:
        c2 += 1
print(min(c, c2))

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

N = len(S)
P = [str(i%2) for i in range(N)]
Q = [str((i+1)%2) for i in range(N)]

PC = 0
QC = 0
for i in range(N):
    if P[i] != S[i]:
        PC += 1
    else:
        QC += 1

print(min(PC,QC))

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

print(min(s[::2].count('0')+s[1::2].count('1'), s[::2].count('1')+s[1::2].count('0')))

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

Solution (Python):
s = list(input())
ans1 = s[::2].count('0')+s[1::2].count('1')
ans2 = s[::2].count('1')+s[1::2].count('0')
print(min(ans1,ans2))

Solution (Python):
*S, = map(int, input())
N = len(S)

ans = 0
for i in range(N-1):
    if S[i]==S[i+1]:
        ans += 1
        S[i+1]^=1
print(ans)

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

a = 0
for i in range(n):
    if i % 2 == 0:
        if s[i] != "0":
            a += 1
    else:
        if s[i] != "1":
            a += 1

b = 0
for i in range(n):
    if i % 2 == 0:
        if s[i] != "1":
            b += 1
    else:
        if s[i] != "0":
            b += 1

print(min(a, b))

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

res = 0

for i in range(1, len(S)):
    if S[i] == S[i-1]:
        res += 1
        S[i] = "0" if int(S[i]) else "1"
print(res)

Solution (Python):
s = list(input())
s2 = s.copy()
s_cnt, s2_cnt = 0, 0
if s[0] == '1':
    s2[0] = '0'
    s2_cnt += 1
else:
    s2[0] = '1'
    s2_cnt += 1

for i in range(1, len(s)):
    if s[i] == s[i-1]:
        s_cnt += 1
        if s[i-1] == '1':
            s[i] = '0'
        else:
            s[i] = '1'
    if s2[i] == s2[i-1]:
        s2_cnt += 1
        if s2[i-1] == '1':
            s2[i] = '0'
        else:
            s2[i] = '1'
print(min(s_cnt, s2_cnt))

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

Solution (Python):
def turn(n):
    if n=='0':
        return '1'
    else:
        return '0'
    
s = input()
n = len(s)
s = list(s)
count = 0
for i in range(n-1):
    if s[i]==s[i+1]:
        s[i+1] = turn(s[i+1])
        count += 1
print(count)

Solution (Python):
S=input()
A=[int(S[i]) for i in range(0,len(S))]
s1=0
for i in range(0,len(S)):
    if i%2==0:
        s1+=0^A[i]
    else:
        s1+=1^A[i]
s2=0
for i in range(0,len(S)):
    if i%2==0:
        s2+=1^A[i]
    else:
        s2+=0^A[i]
print(min(s1,s2))

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

Solution (Python):
def turn(n):
    if n=='0':
        return '1'
    else:
        return '0'
    
s = input()
n = len(s)
s = list(s)
count = 0
for i in range(n-1):
    if s[i]==s[i+1]:
        s[i+1] = turn(s[i+1])
        count += 1
print(count)

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

u = 0
ans = 0
for i in t:
    if u != i:
        ans += 1
    u = 1 if u == 0 else 0

print(min(ans, lt-ans))

Solution (Python):
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

s = input()
snp = np.array(list(map(int,s)))

cand1 = (1 == snp[0::2]).sum() + (0 == snp[1::2]).sum()
cand2 = (0 == snp[0::2]).sum() + (1 == snp[1::2]).sum()

print(min(cand1,cand2))