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()
n = len(s)

a = '0'
b = '1'
for i in range(1,n):
    if a[i-1] == '0':
        a += '1'
    else:
        a += '0'
for i in range(1,n):
    if b[i-1] == '0':
        b += '1'
    else:
        b += '0'

ca, cb = 0, 0
for i in range(n):
    if a[i] != s[i]:
        ca += 1
    if b[i] != s[i]:
        cb += 1

print(min(ca,cb))

Solution (Python):
s = list(map(int, list(input())))
c01 = sum([1 for i, j in enumerate(s) if i % 2 == j])
c10 = sum([1 for i, j in enumerate(s) if i % 2 != j])
print(min(c01, c10))

Solution (Python):
s = list(input())
t = s
S = s+ ['0']
T = t+ ['1']
answ = 0
ansb = 0

for i in range(len(s)):
  if S[i] == '0' and S[i-1] == '0':
    S[i] = '1'
    answ += 1
  elif S[i] == '1' and S[i-1] == '1':
    S[i] = '0'
    answ += 1
    
  if T[i] == '1' and T[i-1] == '1':
    T[i] = '0'
    ansb += 1
  elif T[i] == '0' and T[i-1] == '0':
    T[i] = '1'
    ansb += 1
    
print(min(ansb,answ))

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

Solution (Python):
S = input()

l0 = [0 if i % 2 == 0 else 1 for i in range(len(S))]
l1 = [1 if i % 2 == 0 else 0 for i in range(len(S))]

gap0 = 0
gap1 = 0
for i in range(len(S)):
    if l0[i] != int(S[i]):
        gap0 += 1
    if l1[i] != int(S[i]):
        gap1 += 1

print(min(gap0, gap1))

Solution (Python):








import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count







S = S()

S1 = list(map(int,S[::2]))
S2 = list(map(int,S[1::2]))
ans = sum(S1)+len(S2)-sum(S2)
P(min(len(S)-ans,ans))

Solution (Python):
s=[int(i) for i in input()]
ans=0
for i in range(1,len(s)):
	ans+=s[~-i]==s[i]
	s[i]=not s[~-i]
print(ans)

Solution (Python):
S = list(input())
N = len(S)
T = [S[i] for i in range(N)]
c1 = 0

for i in range(1,N):
  if T[i] == T[i-1]:
    if T[i-1] == '0':
      T[i] = '1'
      c1 += 1 
    else:
      T[i]= '0'
      c1 += 1

if  S[0] == '0':
  S[0] = '1'
else:
  S[0] = '0'
c2 = 1
for i in range(1,N):
  if S[i] == S[i-1]:
    if S[i-1] == '0':
      S[i] = '1'
      c2 += 1 
    else:
      S[i]= '0'
      c2 += 1

print(min(c1,c2))

Solution (Python):
S = list(input())
ans1 = 0
ans2 = 0

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


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

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

Solution (Python):
S = input()
A = '01'*(len(S)//2)+'0'*(len(S)%2)

c = 0

for i,j in zip(S,A):
    if i != j:
        c +=1

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

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

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

Solution (Python):

S = list(input())


length = len(S)
if len == 1:
    print(0)
else:
    bwb = ["0", "1"]
    wbw = ["1", "0"]
    cnt = [0] * 2
    for i in range(length):
        if S[i] == bwb[i % 2]:
            cnt[0] += 1
        if S[i] == wbw[i % 2]:
            cnt[1] += 1

    print(min(cnt))

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

def f(b):
    count = 0
    for i in range(a):
        if s[i] != b:
            count += 1

        if b == '0':
            b = '1'
        else:
            b = '0'
    return count

print(min(f('0'), f('1')))

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

pattern_01 = 0
pattern_10 = 0

for idx, s in enumerate(S):
    if idx % 2 == 0 and s == "1":
        pattern_01 += 1
    elif idx % 2 == 0 and s == "0":
        pattern_10 += 1
    elif idx % 2 == 1 and s == "1":
        pattern_10 += 1
    elif idx % 2 == 1 and s == "0":
        pattern_01 += 1

print(min(pattern_01, pattern_10))

Solution (Python):
s = input()
s_len = len(s)
if s_len == 1:
    print(0)
else:
    dum1 = s[0::2].count("0")
    dum2 = s[1::2].count("1")
    ans1 = s_len-dum1-dum2

    dum3 = s[0::2].count("1")
    dum4 = s[1::2].count("0")
    ans2 = s_len-dum3-dum4
    print(min(ans1,ans2))

Solution (Python):
S = input()
ans1 = 0
ans2 = 0
flag = True
for s in S:
    if flag:
        flag = False
        if s == '0':
            ans1 += 1
        else:
            ans2 += 1
    else:
        flag = True
        if s == '0':
            ans2 += 1
        else:
            ans1 += 1
print(min(ans1, ans2))

Solution (Python):
s=input()
k0=0
k1=0
g0=0
g1=0
for i in range(len(s)):
    if i%2==0:
        if s[i]=="0":
            k0+=1
        else:
            k1+=1
    else:
        if s[i]=="0":
            g0+=1
        else:
            g1+=1
print(min(k0+g1,k1+g0))

Solution (Python):
s = input()
l = len(s)
bo=s[::2].count('0')
be=s[1::2].count('0')
ans = 0
if be>=bo:
    ans += l//2-be + bo
elif l%2!=0:
    ans += l//2+1-bo + be
else:
    ans += l//2-bo + be
print(ans)

Solution (Python):

S = input()
N = len(S)


def create(N, b, c):
    a = ""
    i = 0
    while i < (N // 2):
        a += b + c
        i += 1
    if N % 2 == 1:
        a += b
    lst = [0 for i in range(N) if a[i] == S[i]]
    return len(lst)


print(min(create(N, '1', '0'), create(N, '0', '1')))

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

print(ans)

Solution (Python):
S=list(input())
N=len(S)
n=N//2
if S[0]=='0':
  L=['0','1']*(n+1)
else:
  L=['1','0']*(n+1)
ans=0
for n in range(N):
  if S[n]!=L[n]:
    ans+=1
print(ans)

Solution (Python):
S = input()
count_1 = 0
count_2 = 0
for i,s in enumerate(S):
    if i % 2 == 0 and s == '0':
        count_1 += 1
    elif i % 2 != 0 and s == '1':
        count_1 += 1
for i,s in enumerate(S):
    if i % 2 == 0 and s == '1':
        count_2 += 1
    elif i % 2 != 0 and s == '0':
        count_2 += 1
print(min(count_1,count_2))

Solution (Python):
S = input()
l_even = len(S[0::2])
l_odd = len(S[1::2])

white_even = S[0::2].count('0')
black_even = l_even - white_even
white_odd = S[1::2].count('0')
black_odd = l_odd - white_odd

print(min(white_even + black_odd, white_odd + black_even))

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

Solution (Python):
S = input()

temp = S[0]
ans = 0
for i in S[1:]:
    if i==temp:
        i = '1' if temp == '0' else '0'
        ans += 1
    temp = i 

print(ans)

Solution (Python):
S = input()
c1, c2 = 0, 0

for i, b in enumerate(S):
    b = int(b)
    if b != i%2:
        c1 += 1
    if b != (i+1)%2:
        c2 += 1

print(min(c1, c2))

Solution (Python):
t = list(input())
S = [int(x) for x in t]
cnt1 = 0
cnt2 = 0

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

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

Solution (Python):

import sys


def solve(S: str):
    a = S[::2].count("1") + S[1::2].count("0")
    b = S[::2].count("0") + S[1::2].count("1")
    print(min(a, b))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  
    solve(S)


if __name__ == '__main__':
    main()

Solution (Python):


import sys






















def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    

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

    s = input()
    n = len(s)
    
    zero_one = [None] * n
    one_zero = [None] * n
    tmp = [['0', '1'], ['1', '0']]
    for i in range(n):
        zero_one[i] = tmp[i % 2][0]
        one_zero[i] = tmp[i % 2][1]
    
    print(min(calc_diff(s, ''.join(zero_one)), calc_diff(s, ''.join(one_zero))))


if __name__ == "__main__":
    main()

Solution (Python):
n=input()
a=""
b=""
l=len(n)
for i in range(l):
    if i%2==0:
        a+="0"
        b+="1"
    else:
        a+="1"
        b+="0"
a_ans=0
b_ans=0
for j in range(l):
    if a[j]!=n[j]:
        a_ans+=1
    else:
        b_ans+=1
print(min(a_ans,b_ans))

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

Solution (Python):
s = str(input())
n = len(s)
rcount = 0
for i in range(n):
  if int(s[0]) % 2 == 0:
    if i % 2 == 0:
      if int(s[i]) % 2 == 1:
        rcount += 1
    else:
      if int(s[i]) % 2 == 0:
        rcount += 1
  if int(s[0]) % 2 == 1:
    if i % 2 == 0:
      if int(s[i]) % 2 == 0:
        rcount += 1
    else:
      if int(s[i]) % 2 == 1:
        rcount += 1
print(rcount)

Solution (Python):
n = input()

black = []
white = []
bit = 0
for i in range(len(n)):
    black.append(bit)
    white.append(bit ^ 1)
    bit ^= 1

black_cnt = 0
white_cnt = 0
for i in range(len(n)):
    if black[i] != int(n[i]):
        black_cnt += 1
    if white[i] != int(n[i]):
        white_cnt += 1

print(min(black_cnt, white_cnt))

Solution (Python):
s = list(map(int,input()))
n_s = []
r_s = []

for i in range(len(s)):
    if i%2 == 0:
        n_s.append(0)
    else:
        n_s.append(1)

for i in range(len(s)):
    if i%2 == 0:
        r_s.append(1)
    else:
        r_s.append(0)

cnt = 0
cnt_n = 0
for i in range(len(s)):
    if s[i] != n_s[i]:
        cnt+=1
    if s[i] != r_s[i]:
        cnt_n+=1

print(min(cnt_n,cnt))

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

if len(s) == 1:
    print(0)
    exit()

expected_b = s[0]
ans = 0
for b in s:
    if b != expected_b:
        ans += 1
    expected_b = not expected_b

print(ans)

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

Solution (Python):
s = input()
count_0 = 0
count_1 = 0

l = len(s)


for i in range(l):
    
    if i % 2 == 0:
        if s[i] == "1":
            count_0 += 1
    else:
        
        
        if s[i] == "0":
            count_0 += 1
            


for i in range(l):
    if i % 2 == 0:
        if s[i] == "0":
            count_1 += 1
    else:
        if s[i] == "1":
            count_1 += 1





print(min(count_0, count_1))

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

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

Solution (Python):
import sys
import math
import bisect

def solve(s):
    n = len(s)
    val1 = 0
    
    for i in range(n):
        if i % 2 == 0 and s[i] != '0':
            val1 += 1
        elif i % 2 == 1 and s[i] != '1':
            val1 += 1
    val2 = 0
    
    for i in range(n):
        if i % 2 == 0 and s[i] != '1':
            val2 += 1
        elif i % 2 == 1 and s[i] != '0':
            val2 += 1
    return min(val1, val2)

def main():
    print(solve(input()))

if __name__ == "__main__":
    main()

Solution (Python):
import itertools
import math
import fractions
import functools
import copy

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

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

print(min(count1,count2))

Solution (Python):
import math
import copy

neko = 0
nuko = 0
s = input()
a = ["0","1"]
for i in range(len(s)):
    if s[i] == a[i%2]:
        neko += 1
    if s[i] == a[(i+1)%2]:
        nuko += 1
if neko > nuko:
    neko = nuko
print(neko)

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    S = input().rstrip('\n')
    l = len(S)
    ws = bs = ''
    for i in range(l):
        if i%2 == 0:
            ws += '0'
            bs += '1'
        else:
            ws += '1'
            bs += '0'
    wsc = bsc = 0
    for i in range(l):
        if S[i] != ws[i]:
            wsc += 1
        if S[i] != bs[i]:
            bsc += 1
    print(min(wsc, bsc))

if __name__ == '__main__':
    main()

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    S = input().rstrip('\n')
    l = len(S)
    ws = bs = ''
    for i in range(l):
        if i%2 == 0:
            ws += '0'
            bs += '1'
        else:
            ws += '1'
            bs += '0'
    wsc = bsc = 0
    for i in range(l):
        if S[i] != ws[i]:
            wsc += 1
        if S[i] != bs[i]:
            bsc += 1
    ans = min(wsc, bsc)
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
s=input()
e=0
o=0
n=len(s)

for i in range(n):
    if i%2==0 and s[i]=="1":
        e+=1
    elif i%2==0 and s[i]=="0":
        o+=1
    elif i%2==1 and s[i]=="0":
        e+=1
    else:
        o+=1
print (min(e,o))

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    cunt1=0
    for i,ss in enumerate(s):
        if int(ss)==i%2:cunt1+=1
    cunt2=0
    for i,ss in enumerate(s):
        if int(ss)!=i%2:cunt2+=1   
    print(min(cunt1,cunt2))

if __name__=='__main__':
    main()

Solution (Python):
S = list(map(int, input().rstrip()))

plan_0 = [i % 2 for i in range(len(S))]
plan_1 = [i % 2 for i in range(1, len(S)+1)]

x = sum([(plan_0[i] - S[i]) != 0 for i in range(len(S))])
y = sum([(plan_1[i] - S[i]) != 0 for i in range(len(S))])

print(min(x, y))

Solution (Python):
S = list(map(int, input().rstrip()))

plan_0 = [i % 2 for i in range(len(S))]
plan_1 = [i % 2 for i in range(1, len(S)+1)]

x = len(S) - sum([(plan_0[i] - S[i])==0 for i in range(len(S))])
y = len(S) - sum([(plan_1[i] - S[i])==0 for i in range(len(S))])

print(min(x, y))

Solution (Python):
s = input()
cnt = 0
check = '10'*(len(s)//2) + '1'*(len(s) % 2)
for a, b in zip(s, check):
    if a != b:
        cnt += 1
print(min(cnt, len(s)-cnt))

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


now=s[0]
cnt=0
for i in range(1,n):
    if s[i]==now:
        cnt+=1
        if s[i]=='0':
            s[i]='1'
            now='1'
        else:
            s[i]='0'
            now='0'
    else:
        now=s[i]

print(cnt)

Solution (Python):
s = list(input())
n = len(s)
t = 0
odd = 0
even = 0
while t < n:
  odd += int(s[t])
  t += 2
u = 1
while u < n:
  even += int(s[u])
  u += 2
if n%2 == 0:
  print(min(n//2+odd-even,n//2+even-odd))
else:
  print(min(n//2+odd-even,n//2+even+1-odd))

Solution (Python):
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
def main():
    s=S()
    b_start=0
    w_start=1
    num_whenbstart=0
    num_whenwstart=0
    for i in range(len(s)):
        if int(s[i])!=b_start:
            num_whenbstart+=1
        if int(s[i])!=w_start:
            num_whenwstart+=1
        b_start=0 if b_start%2==1 else 1
        w_start=0 if w_start%2==1 else 1
    print(min(num_whenwstart,num_whenbstart))

if __name__ == '__main__':
    main()

Solution (Python):
s = input()
l = len(s)
S =[]
for i in range(l):
    S.append(int(s[i]))
m = [1]
n = [0]
for i in range(1,l):
    if i % 2 == 1:
        m.append(0)
        n.append(1)
    else:
        m.append(1)
        n.append(0)
ans1 = 0
ans2 = 0
for i in range(l):
    if m[i] != S[i]:
        ans1 += 1
    if n[i] != S[i]:
        ans2 += 1
print(min(ans1,ans2))

Solution (Python):
cnt=0
l=list(input())

for i in range(len(l)-1):
    if l[i]==l[i+1]:
        if l[i]=='0':
            l[i+1]='1'
            cnt +=1
        else:
            l[i+1]='0'
            cnt+=1
     
print(cnt)

Solution (Python):
S = [int(x) for x in input()]
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)
one = 0
two = 0
for i in range(l):
  if i % 2 == 0:
    if s[i] == '0':
      one += 1
    else:
      two += 1
  else:
    if s[i] == '1':
      one += 1
    else:
      two += 1

print(min(one , two))

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

Solution (Python):
s = input()
cnt_b = 0
cnt_w = 0
i = 1
for l in s:
    if i % 2 == 1:
        if l == '1':
            cnt_b += 1
        else:
            cnt_w += 1
    else:
        if l == '1':
            cnt_w += 1
        else:
            cnt_b += 1
    i += 1
print(min(cnt_b, cnt_w))

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

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

zero = []
one = []

zerocount = 0
onecount = 0

for i in range(len(S)):
    if i%2 == 0:
        zero.append(0)
        one.append(1)
    else:
        zero.append(1)
        one.append(0)

for i in range(len(S)):
    if zero[i] != S[i]:
        zerocount += 1
    if one[i] != S[i]:
        onecount += 1

if zerocount<onecount:
    print(zerocount)
else:
    print(onecount)

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

p = ["0", "1"]
f = 1
ans = [0, 0]

for i in s:
    if (p[f] != i):
        ans[0] += 1
    else:
        ans[1] += 1
    f ^= 1

print(min(ans))

Solution (Python):
A=list(input())
A=list(map(int,A))
ansA=0
ansB=0
for i in range(len(A)):
    if i%2==0:
        if A[i]==0:
            pass
        else:
            ansA+=1
    else:
        if A[i]==1:
            pass
        else:
            ansA+=1
for i in range(len(A)):
    if i%2==1:
        if A[i]==0:
            pass
        else:
            ansB+=1
    else:
        if A[i]==1:
            pass
        else:
            ansB+=1
print(min(ansA,ansB))

Solution (Python):
S = input()
N = len(S)
cand1 = '01' * (N // 2) + '0' * (N % 2)
cand2 = '10' * (N // 2) + '1' * (N % 2)

count1 = 0
count2 = 0
for i in range(N):
    if S[i] != cand1[i]:
        count1 += 1
    if S[i] != cand2[i]:
        count2 += 1
        
ans = min(count1, count2)
print(ans)

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

Solution (Python):

import sys

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement


from operator import itemgetter
from sys import stdin

from operator import mul
from functools import reduce
from collections import Counter





j=0
k=0
n=3
r=1
a=[0]






"1行1つの整数を入力を取得し、整数と取得する"




"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

for i in number_list:
    print(number_list[i-1])

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''



"正方行列にstr型の値を入力"
'''




'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"


'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''











'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''




"aという変数に入っているものを大文字にして出力"

















'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''


'''
def cmb(n,r):
    
    r= min(n-r,r)
    
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    
    
    

    under = reduce(mul, range(1, r+1))
    
    
    
    

    return over // under
    
    
    
    
a = cmb(n, r)

'''

'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD

combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''




for i in a.most_common(n):print(i)





 


'''









'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''

'''
素数の判定
'''


def is_prime(n):
    if n == 1: return False

    for k in range(2, int(np.sqrt(n)) + 1):
        
        if n % k == 0:
            return False
            
    return True


'''
npのmaxとmaximumの違い
xs = np.array([1, -2, 3])
np.max(xs, 0)
この出力は3となります．[1, -2, 3]と0の4つの数字のうち，最も大きい値を出力します．

一方で，[max(1, 0), max(-2, 0), max(3, 0)]を出力したい時があります．
その時は，numpyのmaximum関数を用います．

xs = np.array([1, -2, 3])
np.maximum(xs, 0)  

'''

def factorial(x, mod=10**9+7):
    
    
    
    tmp = 1
    for i in range(1, x+1):
        tmp = (tmp * i) % mod
    return tmp
    '''
    Basically, when you do a**d % n, you actually have to calculate a**d, which could be quite large.
    But there are ways of computing a**d % n without having to compute a**d itself, and that is what pow does.
    '''











def main():

    w=1
    j=0
    k=0
    
    
    s=input()
    even=0
    odd=0
    a=[int(i) for i in s]
    
    N=len(s)
    for i in range(N):
        
        if i%2==0 and a[i]==0 :
            even=even+1
        elif i%2==1 and a[i]==1 :
            even=even+1
        else:
            odd=odd+1
    print(min(N-even,N-odd))
    
    '''
    if len(s)%2==1:
     for i in range(N//2):
         if a[2*i]==0 or a[2*i+1]==1:
             even=even+1
         if a[2*i]==1 or a[2*i+1]==0:
             odd=odd+1
     if a[-1]==0 :
         even=even+1
     if a[-1]==1 :
         odd=odd+1

        
        
        
        
    '''
    
    
    
    
    DP = np.zeros(w+1, dtype=int)
    exdp=np.zeros((3,4)) 
    
    
    
        
        
    
    
        
        
    


    "1行1つの整数を入力を取得し、整数と取得する"
    
    
    "12 21 332 とか入力する時に使う"
    "1行に複数の整数の入力を取得し、整数として扱う"
    
    


    
    
    
    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''
    pin_l=["x" for i in range(10)]
    

    ls = ["a", "b", "c", "d", "e"]


    
    

    
    

    
    
    
    
    
    '''
    lsというリストの場合に、1つ飛びの値を取得したい場合には
    ls[::2]
    のようにします。こうすると、
    ["a", "c", "d"]と出力される
    '''

if __name__ == "__main__":
    main()

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

from collections import Counter
def resolve():
    S=input()
    N=len(S)
    s1="01"*(N//2)+"0"*(N%2)
    s2="10"*(N//2)+"1"*(N%2)
    
    ans1,ans2=0,0
    for s in range(N):
        if S[s]!=s1[s]:ans1+=1
        if S[s]!=s2[s]:ans2+=1
    print(min(ans1,ans2))

resolve()

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


s_ = S()
n = len(s_)
s = [int(s_[i]) for i in range(n)]
ans = 0
for i in range(1, n):
    if s[i-1] == s[i]:
        ans += 1
        s[i] ^= 1

ans = min(ans, n-ans)
print(ans)

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

ans = 0

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

print(ans)

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

N=len(S)
dammy1=0
dammy2=0
count=[]

for i in range(N):
    if i%2==0:
        if S[i] != '0':
            dammy1 += 1
    else:
        if S[i] != '1':
            dammy1 += 1
count.append(dammy1)


for i in range(N):
    if i%2==0:
        if S[i] != '1':
            dammy2 += 1
    else:
        if S[i] != '0':
            dammy2 += 1
count.append(dammy2)

print(min(count))

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

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

print(ans)

Solution (Python):
S=input()
cnt=0
pre_s=""
if len(S)==1:
  print(0)
  exit(0)
for i in S:
  if pre_s == "":
    pre_s = "1" if i=="1" else "0"
  elif pre_s == i:
    pre_s = "1" if i=="0" else "0"
    cnt +=1
  else:
    pre_s = i
print(cnt)

Solution (Python):
S = input()

a = 0
b = 0

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

print(min(a, b))

Solution (Python):
Sin = input()
S = list(Sin)
S2 = list(Sin)
N = len(S)

if S[0] == "0":
    S[0] = "1"
else:
    S[0] = "0"

ans1 = 1    
for i in range(1, N):
    if S[i] == S[i-1]:
        if S[i-1] == "0":
            S[i] = "1"
        else:
            S[i] = "0"
        ans1 += 1

ans2 = 0
for i in range(1, N):
    if S2[i] == S2[i-1]:
        if S2[i-1] == "0":
            S2[i] = "1"
        else:
            S2[i] = "0"
        ans2 += 1

print(min(ans1, ans2))