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()
count1 = 0
count2 = 0
for i in range(len(S)):
  if S[i] == '10'[i%2]:
    count1 += 1
  else:
    count2 += 1
print(min([count1,count2]))

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right


from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

S = input()

count = 0
for i in range(len(S)):
    t = int(S[i])
    if i==0:
        b = int(t)
    else:
        if b==0 and t==0:
            count += 1
            b = 1
        elif b==1 and t==1:
            count += 1
            b = 0
        else:
            b = t
print(count)

Solution (Python):
s = list(input())
s1 = s.copy()
s2 = s.copy()
c1 = 0
c2 = 0
for i in range(len(s1)-1):
    if s1[i] == s1[i+1]:
        c1 += 1
        s1[i+1] = '0' if s1[i] == '1' else '1'
for j in range(len(s2)-1, 0, -1):
    if s2[j] == s2[j-1]:
        c2 += 1
        s2[j-1] = '0' if s2[j] == '1' else '1'
print(min(c1, c2))

Solution (Python):
s = input()
l = len(s)
x = 0
y = 0
if (l/2)%2==0:
  a="01"*(l//2)
  b="10"*(l//2)
else:
  a="01"*(l//2)+"0"
  b="10"*(l//2)+"1"
for i in range(l):
  if s[i]!=a[i]:
    x+=1
  if s[i]!=b[i]:
    y+=1
print(min(x,y))

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

Solution (Python):
def main():
    S = input()
    
    s1 = list(map(lambda x: str(x % 2), range(len(S))))
    ans1 = 0
    ans2 = 0
    for i, s in enumerate(S):
        if s1[i] != s:
            ans1 += 1
        else:
            ans2 += 1
    print(min([ans1, ans2]))


if __name__ == "__main__":
    main()

Solution (Python):
S=list(str(input()))
S_int = [int(s) for s in S]
N=len(S)

A1 = [0]*N
A2 = [0]*N
for i in range(N):
  if i%2==0:
    A2[i]=1
  else:A1[i]=1
count1=0
count2=0
for i in range(N):
  if S_int[i]!=A1[i]:
    count1 += 1
  if S_int[i]!=A2[i]:
    count2 += 1
print(min(count1,count2))

Solution (Python):
import itertools
import math

s = input()
n = []
for i in range(len(s)):
    n.append(s[i])

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

print(count)

Solution (Python):
s = input()

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


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

print(min(ans,ans2))

Solution (Python):
s=input()
n=len(s)
if n==1:
  kouho1=[1]
  kouho2=[0]
else:
  kouho1=[0,1]*(n//2)
  kouho2=[1,0]*(n//2)
if n%2==1:
  kouho1.append(0)
  kouho2.append(1)

count1=0
count2=0
for i in range(0,n):
  ss=int(s[i])
  count1+=abs(kouho1[i]-ss)
  count2+=abs(kouho2[i]-ss)
  
print(min(count1,count2))

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

Solution (Python):
s = input()
n = len(s)
case0=0
case1=0

for i in range(n):
  if (i%2==0):
    if s[i]=='0':
      case0 += 1
    else:
      case1 += 1
  else :
    if s[i]=='0':
      case1 += 1
    else :
      case0 += 1

print(min(case0,case1))

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

res0=0
res1=0

for i in range(0,l,2):
	if s[i]=="0":
		res0+=1
	else:
		res1+=1
		
for i in range(1,l,2):
	if s[i]=="1":
		res0+=1
	else:
		res1+=1

print(min(res0,res1))

Solution (Python):
s = input()
ans_ptn1 = ""
ans_ptn2 = ""

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

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

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

Solution (Python):
S=input()

pre = S[0]
ans = 0

for s in S[1:]:
  if pre == s:
    ans += 1
  if pre == "0":
    pre = "1"
  else:
    pre = "0"
print(ans)

Solution (Python):
def main():
    S = input()
    before_c = None
    cnt = 0
    for c in S:
        c = int(c)
        if before_c == c:
            before_c = 1 - c
            cnt += 1
        else:
            before_c = c
    print(cnt)


if __name__ == '__main__':
    main()

Solution (Python):
s = input()

a = ["0", "1"]
b = ["1", "0"]

acount = 0
bcount = 0
for i in range(len(s)):
  if s[i] != a[i%2]:
    acount += 1
  if s[i] != b[i%2]:
    bcount += 1

print(min(acount, bcount))

Solution (Python):
sss = list(map(int, input()))
cnt2 = 0
cnt3 = 0
for i, s in enumerate(sss):
    if i % 2 == 0:
        if s == 1:
            cnt2 += 1
    else:
        if s == 0:
            cnt2 += 1

    if i % 2 == 0:
        if s == 0:
            cnt3 += 1
    else:
        if s == 1:
            cnt3 += 1

print(min(cnt2, cnt3))

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


s=input().rstrip()
n=len(s)
ones=""
zers=""
counto,countz=0,0
for i in range(n):
    if i%2==0:
        ones+="1"
        zers+="0"
    else:
        ones+="0"
        zers+="1"
for i in range(n):
    if ones[i]!=s[i]:
        counto+=1
    if zers[i]!=s[i]:
        countz+=1
print(min(countz,counto))

Solution (Python):
moji = list(str(input()))
cnt =0
if moji[0]=="0":
  for i in range(len(moji)):
    if i%2==0:
      if moji[i]!="0":
        cnt+=1
    else:
      if moji[i]!="1":
        cnt+=1
else:
  for j in range(len(moji)):
    if j%2==0:
      if moji[j]!="1":
        cnt+=1
    else:
      if moji[j]!="0":
        cnt+=1
print(cnt)

Solution (Python):
s = input()
n = len(s)
a = 0
b = 0
for i in range(n):
    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
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    x=len(s)//2
    l1='10'*x+'1'
    l2='01'*x+'0'
    cnt1=0
    cnt2=0
    for i in range(len(s)):
        if s[i]!=l1[i]:
            cnt1+=1
        if s[i]!=l2[i]:
            cnt2+=1
    print(min(cnt1,cnt2))
resolve()

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    x=len(s)//2
    l1=[1,0]*x+[1]
    l2=[0,1]*x+[0]
    cnt1=0
    cnt2=0
    for i in range(len(s)):
        if s[i]!=str(l1[i]):
            cnt1+=1
        if s[i]!=str(l2[i]):
            cnt2+=1
    print(min(cnt1,cnt2))
resolve()

Solution (Python):
S=input()
S0=S[::2]
S1=S[1::2]
S01=S0.count('1')
S00=S0.count('0')
S11=S1.count('1')
S10=S1.count('0')
change=min(S00+S11,S10+S01)
print(change)

Solution (Python):
s=input()
a1=0
a2=0
for i,v in enumerate(s):
    if i%2==0:
        if v=="1":
            a1+=1
        else:
            a2+=1
    else:
        if v=="1":
            a2+=1
        else:
            a1+=1
print(min(a1,a2))

Solution (Python):
n = str(input())
a = "10" * int(len(n)/2) 
b = "01" * int(len(n)/2) 
if int(len(n)) % 2 !=0:
    a +="1"
    b +="0"
s = int(n) + int(a)
t = int(n) + int(b)
p = str(s)
q = str(t)
print(min(p.count("1"),q.count("1")))

Solution (Python):
s = input()
n = len(s)
a = 0
b = 0
for i in range(n):
    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):
S = list(input())
ans = 0

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

Solution (Python):
S = input()
l = len(S)
s1 = ''.join(['0' if i % 2 == 0 else '1' for i in range(l)])
s2 = ''.join(['1' if i % 2 == 0 else '0' for i in range(l)])

t1 = 0
t2 = 0
for i, j, s in zip(s1, s2, S):
    if i != s:
        t1 += 1
    if j != s:
        t2 += 1
print(min(t1, t2))

Solution (Python):


s = input()
s = [int(t) for t in list(s)]
repaint = 0
for i in range(1, len(s)):
    if s[i-1] == s[i]:
        repaint += 1
        s[i] = 1 - s[i]
print(repaint)

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

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

Solution (Python):
s= str(input())
ans = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == '0':
            ans += 1

    else:
        if s[i] == '1':
            ans += 1

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

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

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

Solution (Python):
s = list(input())
x = 0
for i in range(len(s)):
  if i%2 == 0 and s[i] != '0':
    x += 1
  elif i%2 ==1 and s[i] != '1':
    x += 1
y = 0
for i in range(len(s)):
  if i%2 == 0 and s[i] != '1':
    y += 1
  elif i%2 ==1 and s[i] != '0':
    y += 1
print(min(x,y))

Solution (Python):
s = input()
n = len(s)
res0 = "01"*(n//2) + "0"*(n % 2)
res1 = "10"*(n//2) + "1"*(n % 2)
ans0 = 0
ans1 = 0
for i in range(n):
    ans0 += abs(int(res0[i]) - int(s[i]))
    ans1 += abs(int(res1[i]) - int(s[i]))
print(min(ans1, ans0))

Solution (Python):
import numpy as np

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

a01 = np.tile([0,1], len(s)//2)
a10 = np.tile([1,0], len(s)//2)

if len(s)%2 != 0:
    a01 = np.append(a01, 0)
    a10 = np.append(a10, 1)

ans01 = np.abs(s -a01)
ans10 = np.abs(s -a10)

if sum(ans01) >= sum(ans10):
    print(sum(ans10))
else:
    print(sum(ans01))

Solution (Python):
import numpy as np

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

a01 = np.tile([0,1], len(s)//2+1)
a10 = np.tile([1,0], len(s)//2+1)

if len(s)%2 != 0:
    a01 = np.delete(a01, len(s))
    a10 = np.delete(a10, len(s))
else:
    a01 = np.delete(a01, [len(s)-1,len(s)])
    a10 = np.delete(a10, [len(s)-1,len(s)])

ans01 = np.abs(s -a01)
ans10 = np.abs(s -a10)

if sum(ans01) >= sum(ans10):
    print(sum(ans10))
else:
    print(sum(ans01))

Solution (Python):
s=input()

sodd=0
sevn=0

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

print(min(sodd,sevn))

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

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

Solution (Python):
s = list(input())
s1 = []
s2 = []
for i in range(len(s)):
    if i % 2 == 0:
        s1.append('0')
        s2.append('1')
    else:
        s1.append('1')
        s2.append('0')
min_1 = 0

for i in range(len(s)):
    if s[i] != s1[i]:
        min_1 += 1
        
min_2 = 0
for i in range(len(s)):
    if s[i] != s2[i]:
        min_2 += 1
print(min(min_1, min_2))

Solution (Python):
s=list(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
    if i%2 != 0:
        if s[i] == '0':
            c2 += 1
    else:
        if s[i] == '1':
            c2 += 1
print(min(c1,c2))

Solution (Python):
s = input()
n = len(s)
tile1 = ""
tile2 = ""

for i in range(n):
  if i % 2 == 0:
    tile1 += "0"
    tile2 += "1"
  else:
    tile1 += "1"
    tile2 += "0"

ans1 = 0
ans2 = 0

for i in range(n):
  if s[i] == tile1[i]:
    ans1 += 1
  if s[i] == tile2[i]:
    ans2 += 1
    
print(min(ans1, ans2))

Solution (Python):
def coloring_colorfully(s):

    ans = 0
    color = {"0":"1", "1":"0"}

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

    return ans

def main():
    s = list(str(input()))
    print(coloring_colorfully(s))

if __name__ == '__main__':
    main()

Solution (Python):
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

s = list(map(int, input()))
cnt = 0

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

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

ans=0

if s[0]=="0":
    for i in range(1,l):
        if i%2 != 0:
            if s[i] != "1":
                ans+=1
        
        if i%2 == 0:
            if s[i] != "0":
                ans+=1

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

print(ans)

Solution (Python):
s = input()
c1 = 1 if s[0] == '0' else 0
a = []
a.append('1')
for i in range(1,len(s)):
  if s[i] == a[len(a)-1]:
    c1+=1
    a.append('0' if s[i]=='1' else '1')
  else:
    a.append(s[i])
    
a = []
a.append('0')
c2 = 1 if s[0]=='1' else 0
for i in range(1,len(s)):
  if s[i] == a[len(a)-1]:
    c2+=1
    a.append('0' if s[i]=='1' else '1')
  else:
    a.append(s[i])
    
    
print(min(c1,c2))

Solution (Python):


s=list(map(int,list(input())))

tmp=s[0]
ans=0
for i in range(1,len(s)):
    if s[i]==tmp:
        ans+=1
    tmp=(tmp+1)%2
print(ans)

Solution (Python):
c_list = [int(c) for c in input()]
n = len(c_list)

o_count = [0, 0]
for i in range(0, n, 2):
    o_count[int(c_list[i])] += 1

e_count = [0, 0]
for i in range(1, n, 2):
    e_count[c_list[i]] += 1

print(min(o_count[1] + e_count[0], o_count[0] + e_count[1]))

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

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

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
s = list(input()[:-1])
n = len(s)


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


res2 = 0
for i in range(n):
    if i%2 == 0 and s[i] == '1':
        res2 += 1
    elif i%2 == 1 and s[i] == '0':
        res2 += 1
print(min(res,res2))

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

se = [0]*s
so = [0]*s

for i in range(s):
  if i%2 == 0:
    se[i] = 1
  else:
    so[i] = 1

ce = 0
co = 0

for j in range(s):
   x = int(S[j])
   if x != se[j]:
      ce += 1
   if x != so[j]:
      co += 1

print(min(ce,co))

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

    ans = 1000000000
    
    for iro in range(2):
        cnt = 0
        for idx, s in enumerate(S):
            if idx % 2 == 0 and str(iro) != s: cnt += 1
            elif idx % 2 != 0 and str(iro) == s: cnt += 1
        
        ans = min(ans, cnt)

    print(ans)
if __name__ == '__main__':
    solve()

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

    ans = len(S)
    
    for iro in range(2):
        cnt = 0
        for idx, s in enumerate(S):
            if idx % 2 == 0 and str(iro) != s: cnt += 1
            elif idx % 2 != 0 and str(iro) == s: cnt += 1
        
        ans = min(ans, cnt)

    print(ans)
if __name__ == '__main__':
    solve()

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

    ans = len(S)
    
    for iro in range(2):
        cnt = 0
        for idx, s in enumerate(S):
            if idx % 2 == 0 and str(iro) != s: cnt += 1
            if idx % 2 != 0 and str(iro) == s: cnt += 1
        
        ans = min(ans, cnt)

    print(ans)
if __name__ == '__main__':
    solve()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    S = list(input())
    

    
    iro = S[0]
    cnt1 = 0
    for idx, s in enumerate(S):
        if idx % 2 == 0 and s != iro:
            cnt1 += 1
        elif idx % 2 != 0 and s == iro:
            cnt1 += 1

    
    cnt2 = 0
    for idx, s in enumerate(S):
        if idx % 2 == 0 and s == iro:
            cnt2 += 1
        elif idx % 2 != 0 and s != iro:
            cnt2 += 1

    print(min(cnt1, cnt2))



if __name__ == '__main__':
    solve()

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

s1 = "01" * (N // 2)
s2 = "10" * (N // 2)

if N % 2 == 1:
    s1 += "0"
    s2 += "1"

diff1 = 0
diff2 = 0

for i in range(N):
    if S[i] != s1[i]:
        diff1 += 1
    if S[i] != s2[i]:
        diff2 += 1

print(min(diff1, diff2))

Solution (Python):
s = input()
n = len(s)
start_1 = [0] * n
start_0 = [0] * n

for i in range(n):
    if i % 2 == 0:
        start_1[i] = 1
    else:
        start_0[i] = 1
        
d1 = 0
d2 = 0

for i in range(n):
    x = int(s[i])
    
    if x != start_1[i]:
        d1 += 1
        
    if x != start_0[i]:
        d2 += 1
        
print(min(d1,d2))

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

Solution (Python):
s=input()
l=[]
for i in range(len(s)):
    l.append(s[i])

cnt=0
for i in range(1,len(l)):
    if l[i] != l[i-1]:
        continue
    else:
        cnt+=1
        if l[i-1]=="1":
            l[i]="0"
        else:
            l[i]="1"

print(cnt)

Solution (Python):
s = input()

count1=0
count2=0

for i, name in enumerate(s):  
  if i%2==0:
    if name=='0':
      count1+=1
    else:
      count2+=1
  else:
    if name!='0':
      count1+=1
    else:
      count2+=1
print(min(count1, count2))

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

def zo(a):
  if a==1:
    b=0
  else:
    b=1
  return b

vol = len(s)
klist = s
glist = s
nk = 1
ng = 0
k=0
g=0

for i in range(vol):
  if klist[i]!=nk:
    k=k+1
  if glist[i]!=ng:
    g=g+1
  nk = zo(nk)
  ng = zo(ng)

if k>=g:
  print(g)
else:
  print(k)

Solution (Python):
a=input()
ct1=0
ct2=0
for i in range(len(a)):
    if (i+1)%2==0:
        if a[i]!='0':
            ct1+=1
        else:
            ct2+=1
    else:
        if a[i]=='0':
            ct1+=1
        else:
            ct2+=1
if ct1>ct2:
    print(ct2)
else:
    print(ct1)

Solution (Python):
import math
import sys
def makestr(i):
    if (i % 2 == 0):
        return '0'
    else:
        return '1'
s = input()
candicate1 = ''
candicate2 = ''
for i in range(len(s)):
    candicate1 += makestr(i)
    candicate2 += makestr(i + 1)
ans1 = 0
ans2 = 0
for i in range(len(s)):
    if (candicate1[i] != s[i]):
        ans1 += 1
    else:
        ans2 += 1
print(min(ans1,ans2))

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

Solution (Python):


s = str(input())

odd0 = 0
odd1 = 0
even0 = 0
even1 = 0

for i in range(len(s)):
    if i%2==0:
        if int(s[i])%2==0:
            even0 += 1
        else:
            even1 += 1
    else:
        if int(s[i])%2==0:
            odd0 += 1
        else:
            odd1 += 1

print(min(even0+odd1, even1+odd0))

Solution (Python):
s=input()
n=len(s)
cnt_b=0
cnt_w=0

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


for i in range(n):
  if i%2==1:
    if s[i]!="0":
      cnt_w+=1
  else:
    if s[i]!="1":
      cnt_w+=1
      
print(min(cnt_b,cnt_w))

Solution (Python):
from collections import Counter
n=input()
o=Counter(n[0::2])
e=Counter(n[1::2])
m=len(n)-max(o["0"]+e["1"],o["1"]+e["0"])
print(m)

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

Solution (Python):
s=input()
g=0
for i in range(len(s)):
    if i%2==0:
        if s[i]=='0':
            g+=1
    else:
        if s[i]=='1':
            g+=1
c=0
for i in range(len(s)):
    if i%2==0:
        if s[i]=='1':
            c+=1
    else:
        if s[i]=='0':
            c+=1
if g>c:
    print(c)
else:
    print(g)

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

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

black = ""

for i in range(l):
  if i%2 == 0:
    black = black + "0"
  else:
    black = black + "1"

bswap = 0
wswap = 0

for i in range(l):
  if s[i] != black[i]:
    bswap += 1
  else:
    wswap += 1
print(min(bswap,wswap))

Solution (Python):


import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

S = input()

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

print(min(w, b))

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

Solution (Python):
s=input()
a=s[0]
cnt=0
for i in s[1:]:
    if i==a:
        cnt+=1
        if i=="0":
            a="1"
        else:
            a="0"
    else:
        a=i
print(cnt)

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

ans = 0

for i in range(len(S)-1):
    if S[i]!=S[i+1]:
        continue
    if S[i+1]=="0":
        ans = ans + 1
        S[i+1] = "1"
    else:
        ans = ans + 1
        S[i+1] = "0"

print(ans)

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

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

Solution (Python):
s = list(input())
b = s[0]
cnt = 0
for w in s[1:]:
    if w == b:
        cnt += 1
        if w == "0":
            b = "1"
        else:
            b = "0"
    else:
        b = w
print(cnt)

Solution (Python):
def compare(s1, s2):
    ans = 0
    for i in range(len(s1)):
        if s1[i] == s2[i]: ans += 1
    return ans

s = input()
n = len(s)
s1 = ('01' * n)[:n]
s2 = ('10' * n)[:n]
print(min(n - compare(s1, s), n - compare(s2, s)))

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

Solution (Python):
s = input()
left = s[0]
ans = 0

if int(s[0]) % 2 == 0:
    num = 0
else:
    num = 1
    
for i in range(1, len(s)):
    if left == s[i]:
        ans += 1
    left = str((i + num) % 2)

print(ans)

Solution (Python):
S = list(map(int, list(input())))
even = [0]*2
odd = [0]*2
for i, s in enumerate(S):
  if i % 2 == 0:
    even[s] += 1
  else:
    odd[s] += 1
ans = min(even[0]+odd[1], even[1]+odd[0])
print(ans)

Solution (Python):
def diff(a,b):
    output = 0
    for i in range(N):
        if a[i] != b[i]:
            output += 1
    return output

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"

ans = min(diff(S,S1),diff(S,S2))
print(ans)

Solution (Python):
import sys
s = input()
n = len(s)
ans =0
ans += s[0::2].count("0")
ans += s[1::2].count("1")
if  n / 2 <= ans:
    print(n - ans)
else:
    print(ans )

Solution (Python):
s = input()

bw = []
for i in range(len(s)):
    if i % 2 == 0:
        bw.append('1')
    else:
        bw.append('0')

p1 = 0
t = ''.join(bw)
for i in range(len(s)):
    if s[i] != t[i]:
        p1 += 1

bw = []
for i in range(len(s)):
    if i % 2 == 0:
        bw.append('0')
    else:
        bw.append('1')

p2 = 0
t = ''.join(bw)
for i in range(len(s)):
    if s[i] != t[i]:
        p2 += 1
ans = min(p1, p2)
print(ans)

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


count1 = 0
for i in range(N - 1):
    if S[0] == '0':
        if (i + 1) % 2 == 1 and S[i + 1] != '1':
            count1 += 1
        elif (i + 1) % 2 == 1 and S[i + 1] != '0':
            continue
        elif (i + 1) % 2 == 0 and S[i + 1] != '1':
            continue
        elif (i + 1) % 2 == 0 and S[i + 1] != '0':
            count1 += 1
    else:
        if (i + 1) % 2 == 1 and S[i + 1] != '0':
            count1 += 1
        elif (i + 1) % 2 == 1 and S[i + 1] != '1':
            continue
        elif (i + 1) % 2 == 0 and S[i + 1] != '0':
            continue
        elif (i + 1) % 2 == 0 and S[i + 1] != '1':
            count1 += 1

print(count1)

Solution (Python):
a=str(input())
i=0
sw=0
cou1=0
cou2=0
while i<len(a):
  if sw==0:
    if a[i]!="0":
      cou1+=1
    sw=1
  else:
    if a[i]!="1":
      cou1+=1
    sw=0
  i+=1
sw=1
i=0

while i<len(a):
  if sw==0:
    if a[i]!="0":
      cou2+=1
    sw=1
  else:
    if a[i]!="1":
      cou2+=1
    sw=0
  i+=1

if cou2>=cou1:
  print(cou1)
else:
  print(cou2)

Solution (Python):
S = list(input())
Ski = S[0:len(S):2]
Sgu = S[1:len(S):2] 
p1 = Ski.count('1') + Sgu.count('0') 
p2 = Ski.count('0') + Sgu.count('1')
print(min(p1,p2))

Solution (Python):
S = list(input())
Ski = S[0:len(S):2]
Sgu = S[1:len(S):2] 
p1 = Ski.count('1') + Sgu.count('0') 
p2 = Ski.count('0') + Sgu.count('1')
if p1>p2:
    print(p2)
else:
    print(p1)