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):
from collections import deque

S = input()

Sint = int(S,2)
Slen = len(S)

def create_wbint(l, start_with_white=True):
    is_white = start_with_white
    wbdeque = deque([])
    for i in range(l):
        if is_white:
            wbdeque.append('0')
        else:
            wbdeque.append('1')
        is_white = not is_white
    return int(''.join(wbdeque),2)


WBint = create_wbint(Slen, start_with_white=True)
BWint = create_wbint(Slen, start_with_white=False)

WBxor = Sint ^ WBint
count_1_in_wb = 0
for c in bin(WBxor):
    if c == '1':
        count_1_in_wb +=1

BWxor = Sint ^ BWint
count_1_in_bw = 0
for c in bin(BWxor):
    if c == '1':
        count_1_in_bw +=1

print(min(count_1_in_wb, count_1_in_bw))

Solution (Python):
s = input()
cnt = 0
if len(s) ==1:
    print("0")
elif len(s) ==2:
    if len(set(s))==1:
        print("1")
    else:
        print("0")
elif len(s) ==3:
    if len(set(s)) == 1:
        print("1")
    else:
        if s[0] == s[2]:
            print("0")
        else:
            print("1")
else:
    pass
if  len(s)>=2 and s[0]==s[1]:
    s = list(s)
    s[1] = str(abs(int(s[0])-1))
    s = "".join(s)
    cnt +=1
if len(s)%2 and len(s)>=4:
    for i in range(0,len(s)+1,2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s),2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)
elif len(s)%2==0 and len(s)>=4:
    for i in range(0,len(s),2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s)+1,2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)

Solution (Python):
s = input()
cnt_a = 0
cnt_b = 0


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


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

print(min(cnt_a, cnt_b))

Solution (Python):
S = input()

s0 = 0
s1 = 0
for i, s in enumerate(list(S)):
    s0 += int(str(i % 2) == s)
    s1 += int(str((i + 1) % 2) == s)
print(min(s0, s1))

Solution (Python):
S = input()

s0 = [0 for i in range(len(S))]
s1 = [1 for i in range(len(S))]
for i in range(0, len(S), 2):
    s0[i] = (s0[i] + 1) % 2
    s1[i] = (s1[i] + 1) % 2

s0 = ''.join(map(str, s0))
s1 = ''.join(map(str, s1))


def cnt(x):
    cnt = 0
    while x > 0:
        cnt += x & 1
        x = x >> 1
    return cnt


print(min(cnt(int(S, 2) ^ int(s0, 2)), cnt(int(S, 2) ^ int(s1, 2))))

Solution (Python):
S = input().strip()
l = len(S)

if l == 1:
    print(0)
    exit()

cnt10 = 0
cnt01 = 0
for i in range(l):
    if i % 2:
        
        if S[i] == '1':
            cnt10 += 1
        else:
            cnt01 += 1
    else:
        
        if S[i] == '0':
            cnt10 += 1
        else:
            cnt01 += 1

print(min(cnt01, cnt10))

Solution (Python):
def count(S, val):
    ret = 0
    for i in range(0, len(S)):
        if S[i] != val:
            ret = ret + 1
        if val == '0':
            val = '1'
        else:
            val = '0'
    return ret
  
def main():
    S = input()
    print(min(count(S,'0'),count(S,'1')))

if __name__ == "__main__":
    main()

Solution (Python):
S = input()
N = len(S)
even = S[0::2]
odd = S[1::2]
ptn0 = N - (even.count('1') + odd.count('0'))
ptn1 = N - (even.count('0') + odd.count('1'))
print(min(ptn0, ptn1))

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

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

a=''
for i in range(n):
        if i%2==0:
                a+='1'
        else:
                a+='0'
c=0
d=0
for j in range(n):
        if s[j]==a[j]:
                c+=1
        else:
                d+=1
print(min(c,d))

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

Solution (Python):
def solve(string):
    return str(
        len(string) - max(sum([s == str(i % 2) for i, s in enumerate(string)]),
                          sum([s == str(i % 2) for i, s in enumerate(string, start=1)])))


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

Solution (Python):
s=list(map(int,str(input())))
n=len(s)
a=0
b=0
for i in range(n):
  if ((i%2)+s[i])%2==0:
    a+=1
  else:
    b+=1
print(n-max(a,b))

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

cnt0=0
cnt1=0

for i in range(n):
  if i%2==0:
    cnt0+=(1-(0^int(s[i])))
    cnt1+=(1&int(s[i]))
  else:
    cnt0+=(1&int(s[i]))
    cnt1+=(1-(0^int(s[i])))
    
print(min(cnt0,cnt1))

Solution (Python):
S = input()
L = []
for i in range(len(S)):
  c = S[i]
  c2 = 0 if c == "0" else 1
  if i%2 == 0:
    c2 = 1-c2
  L.append(c2)
count1 = len(list(filter(lambda c: c == 0, L)))
count2 = len(list(filter(lambda c: c == 1, L)))
count = min(count1, count2)
print(count)

Solution (Python):
s = input()

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

print(min(a1, a2))

Solution (Python):
import numpy as np
S = str(input())
moji1 = "0"
moji2 = "1"
while len(moji1) < len(S):
    if moji1[-1] == "0":
        moji1 += "1"
        moji2 += "0"
    else:
        moji1 += "0"
        moji2 += "1"

Sarr = np.array([int(i) for i in S])
arr1 = np.array(([int(i) for i in moji1]))
arr2 = np.array(([int(i) for i in moji2]))
S1 = np.count_nonzero(Sarr - arr1 != 0)
S2 = np.count_nonzero(Sarr - arr2 != 0)
print(min(S1, S2))

Solution (Python):
s = input()
oddone = ''
evenone = ''

for i in range(len(s)):
    if i % 2 == 1:
        oddone += '1'
        evenone += '0'
    else:
        oddone += '0'
        evenone += '1'

def diffCount(s1, s2):
    count = 0
    if len(s1) != len(s2):
        print('error')
        return

    for i in range(len(s1)):
        if s1[i] != s2[i]:
            count += 1

    return count

print(min(diffCount(s, oddone), diffCount(s, evenone)))

Solution (Python):

import sys


def get_num():
    return int(input())


def get_nums(n):
    res = [0 for _ in range(n)]
    for i in range(n):
        res[i] = int(input())
    return res


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

origin = [int(s) for s in input()]

length = len(origin)
cand_list = [0 for _ in range(length)]
for i in range(0, length, 2):
    cand_list[i] = 1

cnt1 = 0
cnt2 = 0
for i in range(length):
    if origin[i] == cand_list[i]:
        cnt2 += 1
    else:
        cnt1 += 1

print(min(cnt1, cnt2))

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

S_int = int(S, 2)

count_b = 0
black_ff = [str(i % 2) for i in range(N)]
for i, d in enumerate(black_ff):
    if S[i] != d: count_b += 1

count_w = 0
white_ff = ["0" if i % 2 == 1 else "1" for i in range(N)]
for i, d in enumerate(white_ff):
    if S[i] != d: count_w += 1
        
print(min(count_b, count_w))

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

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

txt1 = ''
txt2 = ''

for i in range(l):
    if i%2==0:
        txt1 += '0'
        txt2 += '1'
    else:
        txt1 += '1'
        txt2 += '0'

cnt1 = 0
cnt2 = 0

for i in range(l):
    if s[i] != txt1[i]:
        cnt1 += 1
    if s[i] != txt2[i]:
        cnt2 += 1
print(min(cnt1,cnt2))

Solution (Python):
s = input()
s1 = '01' * (10 ** 5 // 2)
s1 = s1[:len(s)]
count = [0, 0]

for i in range(len(s)):
    if s[i] != s1[i]:
        count[0] += 1
    else:
        count[1] += 1

print(min(count))

Solution (Python):
s = input()
s1 = '01' * (10 ** 5 // 2)
s2 = '10' * (10 ** 5 // 2)
s1 = s1[:len(s)]
s2 = s2[:len(s)]
count = [0, 0]

for i in range(len(s)):
    if s[i] != s1[i]:
        count[0] += 1
    else:
        count[1] += 1

print(min(count))

Solution (Python):


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

S_ = S[:]
cnt_0 = 0
for i in range(1, len(S_)):
	if S_[i] == S_[i-1]:
		S_[i] = (S_[i]+1)%2
		cnt_0 += 1

S_ = S[:]
cnt_1 = 1
S_[0] = (S_[0]+1)%2
for i in range(1, len(S_)):
	if S_[i] == S_[i-1]:
		S_[i] = (S_[i]+1)%2
		cnt_1 += 1
		
print(min(cnt_0, cnt_1))

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

t1='01'*(n//2+1)
t2='10'*(n//2+1)

t1_chk=0
t2_chk=0

for i in range(n):
	if s[i]!=t1[i]:
		t1_chk+=1
	if s[i]!=t2[i]:
		t2_chk+=1

print(min(t1_chk,t2_chk))

Solution (Python):
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''

gi = lambda : list(map(int,input()))
l = gi()
n = len(l)
print(min(sum([abs(k%2 - l[k]) for k in range(n)]), sum([abs((k + 1)%2 - l[k]) for k in range(n)])))

Solution (Python):
import numpy as np

def main():
    S = input()
    S_np = np.array([int(S[i]) for i in range(len(S))])
    final_0_origin = np.array([i % 2 for i in range(len(S))])
    final_1_origin = np.array([(i+1) % 2  for i in range(len(S))])

    ans = min(cal_dist(S_np, final_0_origin), cal_dist(S_np, final_1_origin))
    print(ans)

def cal_dist(S_np, T_np):
    return np.sum(S_np ^ T_np)

main()

Solution (Python):
s = sss = [_ for _ in input()]

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

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

Solution (Python):
sss = [i for i in input()]
n = int(len(sss))
if n%2 == 0:
  g1 = "01"*n
  g2 = "10"*n
else:
  g1 = "01"*int((n-1)/2) + "0"
  g2 = "10"*int((n-1)/2) + "1"
count_1 = 0
count_2 = 0
for i in range(n):
  if not sss[i] == g1[i]:
    count_1 += 1
  if not sss[i] == g2[i]:
    count_2 += 1
print(min(count_1, count_2))

Solution (Python):
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	s = input()
	a = []
	b = []
	for i in range(len(s)//2):
		a.append('1')
		a.append('0')
		b.append('0')
		b.append('1')
	if(len(s)%2==1):
		a.append('1')
		b.append('0')
	ac = 0
	bc = 0
	for i in range(len(s)):
		if(a[i] != s[i]):
			ac+=1
		if(b[i] != s[i]):
			bc+=1
	print(min(ac,bc))

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

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

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Solution (Python):
s = input()

candi = []

candi.append(s[0::2].count('0') + s[1::2].count('1'))
candi.append(s[0::2].count('1') + s[1::2].count('0'))

print(min(candi))

Solution (Python):



s = input()

ans1 = ans2 = 0
for i,c in enumerate(s):
    if str(i&1) == c:
        ans1 += 1
    else:
        ans2 += 1

print(min(ans1,ans2))

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

a = S[0:N:2].count("0")
b = S[1:N:2].count("1")
c = S[0:N:2].count("1")
d = S[1:N:2].count("0")

print(min(a+b,c+d))

Solution (Python):
S = input()
N = len(S)
if  N ==1:
    print(0)
    exit()
a = S[0:N:2].count("0")
b = S[1:N:2].count("1")
c = S[0:N:2].count("1")
d = S[1:N:2].count("0")

print(min(a+b,c+d))

Solution (Python):


import sys

s = input()
n=len(s)

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

print(min(n-num,num))

Solution (Python):
S = input()

def flip_num(goal):
    return sum([0 if S[i] == goal[i] else 1 for i in range(len(S))])

def stripe(zero_first):
    if (zero_first):
        return ['0' if i % 2 == 0 else '1' for i in range(len(S))]
    else:
        return ['0' if i % 2 == 1 else '1' for i in range(len(S))]

print(min(flip_num(stripe(True)), flip_num(stripe(False))))

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

Solution (Python):
S = input()
a=[]
b=[]
for i in range(len(S)):
    if i%2 == 0:
        a.append(0)
        b.append(1)
    else:
        a.append(1)
        b.append(0)
Slist = [int(i) for i in S]
counta=0
countb=0

for i in range(len(Slist)):
    if Slist[i] != a[i]:
        counta+=1
    if Slist[i] != b[i]:
        countb+=1
if counta<=countb:
    print(counta)
else:
    print(countb)

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

if N[0] == 0:
    seikai = [0] * int(len(N))
    for i in range(1, len(N), 2):
        seikai[i] = 1
else:
    seikai = [1] * int(len(N))
    for i in range(1, len(N), 2):
        seikai[i] = 0

ans = 0
for m in range(len(N)):
    if not N[m] == seikai[m]:
        ans += 1

print(ans)

Solution (Python):

from fractions import gcd

from math import factorial as f

from math import ceil,floor,sqrt

from sys import exit

from copy import deepcopy
import numpy as np

import bisect







def main():
    s = list(input())
    s = list(map(int, s))
    scopy = deepcopy(s)
    scopy[0] ^= 1

    cnt = 0
    cntc = 1
    for i in range(1,len(s)):
        if s[i] == s[i-1]:
            s[i] ^= 1
            cnt += 1
        if scopy[i] == scopy[i-1]:
            scopy[i] ^= 1
            cntc += 1
    print(min(cnt,cntc))







main()

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

if S[0] == '0' and N % 2 == 0:
    white_black = [0,1]*(N//2)
elif S[0] == '1' and N % 2 == 0:
    white_black = [1,0]*(N//2)
elif S[0] == '0' and N % 2 == 1:
    white_black = [0,1]*(N//2) + [0]
elif S[0] == '1' and N % 2 == 1:
    white_black = [1,0]*(N//2) + [1]

count = 0

for i in range(N):
    if S[i] != str(white_black[i]):
        count += 1

print(count)

Solution (Python):
s = input().split()[0]

pat_1_list = []
pat_2_list = []

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

change_count_list = []

for pat_list in [pat_1_list, pat_2_list]:
    
    change_count = 0
    for pat_char, s_char in zip(pat_list, s):
        if pat_char != s_char:
            change_count += 1
    change_count_list.append(change_count)


ans = min(change_count_list)

print(ans)

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

even = 0 
odd = 0 

for i,v in enumerate(S_2):
        if i % 2 == 0:
                
                if v == 0:
                        odd += 1
                else:
                        even += 1
        else:
                
                if v == 1:
                        odd += 1
                else:
                        even += 1

print(min(odd,even))

Solution (Python):
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
Mod = 1000000007



def main(): 
    S = input()
    keep = "A"
    ans = 0
    for i in S:
        if keep == "A":
            keep = i
        elif keep == i:
            ans += 1
            keep = ("0" if i == "1" else "1")
        else:
            keep = i
    print(ans)
if __name__ == "__main__":
    main() 




def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n < 2 is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))):
        if prime[i] == 1:
            for j in range(2*i,n):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n):
        if prime[i] == 1:
            res.append(i)
    return res

class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py

    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

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


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

for i in range(n):
    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(n-even0-odd1,n-odd0-even1))

Solution (Python):
stri=input()
c1=0
c2=0
n=len(stri)
i=0

c1beg=0
c2beg=1
while(i<n):
	if(int(stri[i])!=(c1beg%2)):
		c1+=1
	if(int(stri[i])!=(c2beg%2)):
		c2+=1
	c1beg+=1
	c2beg+=1
	i+=1
print(min(c1,c2))

Solution (Python):
S = input()

norm = 0
for i,s in enumerate(S):
    if (i%2) == int(s):
        norm += 1

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

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

ans1 = sum([1 for i in range(N) if i % 2 == 0 and S[i] == "0"]) + sum([1 for i in range(N) if i % 2 != 0 and S[i] == "1"])
ans2 = sum([1 for i in range(N) if i % 2 == 0 and S[i] == "1"]) + sum([1 for i in range(N) if i % 2 != 0 and S[i] == "0"])
print(min(ans1, ans2))

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

cnt = 0
for i in range(leng):
  if i % 2 == int(S[i]):
    cnt += 1

print(min([cnt, leng - cnt]))

Solution (Python):
s=list(map(int,input()))
l=[1,0]*(len(s)//2+1)
r=[0,1]*(len(s)//2+1)
lc=0
rc=0
for i in range(len(s)):
    if s[i]!=l[i]:
        lc+=1
    elif s[i]!=r[i]:
        rc+=1
print(min(lc,rc))

Solution (Python):
def check(s,l,num):
    dif=0
    for i in range(l):
        if s[i] != str(num):
            dif+=1
        num=(num+1)%2
    return dif

s=input()
l=len(s)
print(min(check(s,l,0),check(s,l,1)))

Solution (Python):
def zero(s,l):
    dif=0
    num=0
    for i in range(l):
        if s[i] != str(num):
            dif+=1
        num=(num+1)%2
    return dif

def one(s,l):
    dif=0
    num=1
    for i in range(l):
        if s[i] != str(num):
            dif+=1
        num=(num+1)%2
    return dif

s=input()
l=len(s)
print(min(zero(s,l),one(s,l)))

Solution (Python):
a = input()
count = 0
mojiretu_01 = ""
mojiretu_10 = ""

for i in range(len(a)):
    if i % 2 == 0:
        mojiretu_01 += "0"
        mojiretu_10 += "1"
    else:
        mojiretu_01 += "1"
        mojiretu_10 += "0"
count01 = 0
count10 = 0

for i in range(len(a)):
    if a[i] != mojiretu_01[i]:
        count01 += 1
    else:
        count10 += 1

print(min(count01, count10))

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:
      c2 += 1
  elif i % 2 == 1:
    if s[i] == "0":
      c2 += 1
    else:
      c1 += 1

print(min(c1, c2))

Solution (Python):
S = input()

s1, s2 = 0, 0
for i, s in enumerate(S) :
    if i % 2 != int(s) :
        s1 += 1
    else :
        s2 += 1

print(min(s1, s2))

Solution (Python):


s=list(input())

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

cnta=0
cntb=0

for i in range(len(s)):
    r=i%2
    if s[i]!=a[r]:cnta+=1
    elif s[i]!=b[r]:cntb+=1

print(min(cnta,cntb))

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

aim = 1

for _ in range(int(N/2)):
    aim <<= 2
    aim |= 0b10
if N % 2 == 1 and N != 0:
    aim <<= 1
    aim |= 0b1

S = int(S, 2)
mask = "1" * (N)
mask = int(mask, 2)
aim = aim & mask

differences = bin(S ^ aim)
Num1 = differences.count("1")
Num0 = N - Num1

print(min(Num1, Num0))

Solution (Python):
s="0b"+input()
a=int("0b"+"10"*(len(s)//2-1)+"1"*(len(s)%2==1),0)
s=int(s,0)
c=lambda x:str(bin(x)).count("1")
print(min(c(s^a),c(s^a^int("0b"+"1"*(len(bin(a))-2),0))))

Solution (Python):
S = input()
s01 = 0
s10 = 1
c01 = 0
c10 = 0

for s in S:
    if s01 != int(s):
        c01 += 1
    if s10 != int(s):
        c10 += 1
    s01 = (s01 + 1) % 2
    s10 = (s10 + 1) % 2

print(min(c01, c10))

Solution (Python):
S = str(input())
N = len(S)
ans = 0
count = 0
S = list(S)

odd = [0]*N
for i in range(N//2):
  odd[2*i+1] = 1
  
even = [0]*N
for i in range((N+1)//2):
  even[2*i] = 1

for i in range(N):
  if int(odd[i]) != int(S[i]):
    count += 1

ans = count
count = 0

for i in range(N):
  if int(even[i]) != int(S[i]):
    count += 1
ans = min(ans,count)   

print(ans)

Solution (Python):
S = input()

length = len(S)
pattern1 = ""
for i in range(length):
    pattern1 += "0" if i % 2 == 0 else "1"


count1 = 0
count2 = 0

for i in range(length):
    if pattern1[i] == S[i]:
        count2 += 1
    else:
        count1 += 1

print(min(count1, count2))

Solution (Python):
"""


 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())


 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  


a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 
"""

import math
import sys
import itertools
import queue
from fractions import gcd

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

mod = 1000000007

if __name__ == "__main__":
    s = list(sys.stdin.readline().rstrip())
    ans = 0
    for i in range(len(s)):
        if i%2 == 0 and s[i] == "0":
            ans +=1
        elif i%2 == 1 and s[i] == "1":
            ans +=1
    
    ans2 = 0
    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(ans,ans2))

Solution (Python):
Narray = [n for n in str(input())]

counter = 0
if len(Narray) > 1:
    for n in range(1,len(Narray)):
        if Narray[n] == Narray[n-1]:
            counter+=1
            if  Narray[n] == '1':
                Narray[n] = '0'
            else:
                Narray[n] = '1'

print(counter)

Solution (Python):
s = input()
_s = int(s, 2)
n = len(s)

mask_1 = int(('01' * (n//2+1))[:n], 2)
mask_2 = int(('10' * (n//2+1))[:n], 2)

ans = min(bin(_s ^ mask_1).count('1'), bin(_s ^ mask_2).count('1'))

print(ans)

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

count = 0
for i in range(-(-(len(N))//2)):
	if N[2*i] == 1:
		count += 1

for i in range(len(N)//2):
	if N[2*i+1] == 0:
		count += 1

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

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

Solution (Python):
Ss = input()

c1 = 0
c2 = 0
for i in range(0, len(Ss)):
    if i & 1:
        if Ss[i] == '0':
            c1 += 1
        else:
            c2 += 1
    else:
        if Ss[i] == '1':
            c1 += 1
        else:
            c2 += 1
print(min([c1, c2]))

Solution (Python):

S = input()
ans = 10000000000000
gl = ["",""]
for i in range(2):
    for j in range(len(S)):
        if j % 2 == i:
            gl[i] += "0"
        else:
             gl[i] += "1"

for i in range(2):
    tmp = 0
    for j in range(len(S)):
        if S[j] != gl[i][j]:
            tmp += 1
    ans = min(ans,tmp)
print(ans)

Solution (Python):
a = input()
a = [bool(int(a[i])) for i in range(len(a))]
b = True
c = 0
d = 0
for i in range(len(a)):
    if b is a[i]:
        c += 1
    if b is not a[i]:
        d += 1
    b = not b
print(min(c, d))

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

ans1 = 0
ans2 = 0

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

print(min(ans1,ans2))

Solution (Python):


S = str(input())

N = len(S)
count_tmp1 = 0
count_tmp2 = 0


for j in range(0,N):
    if j % 2 == 0 and S[j] == '0':
        count_tmp1 += 1
    elif j % 2 == 1 and S[j] == '1':
        count_tmp1 += 1


for j in range(0,N):
    if j % 2 == 0 and S[j] == '1':
        count_tmp2 += 1
    elif j % 2 == 1 and S[j] == '0':
        count_tmp2 += 1

if count_tmp1 >= count_tmp2:
    print(count_tmp2)

else:
    print(count_tmp1)

Solution (Python):



s = list(map(int,list(input())))
n = len(s)
ans1 = 0
ans2 = 0
for i in range(n):
    if i % 2 == 0:
        if s[i] != 1:
            ans1 += 1
    else:
        if s[i] != 0:
            ans1 += 1
for i in range(n):
    if i % 2 == 0:
        if s[i] != 0:
            ans2 += 1
    else:
        if s[i] != 1:
            ans2 += 1
print(min(ans1,ans2))

Solution (Python):
s = input()
n = len(s)
zero = ""
one = ""
for i in range(n):
  if i%2 == 0:
    zero += "0"
    one += "1"
  else:
    zero += "1"
    one += "0"
z = 0
o = 0
for i in range(n):
  tmp = s[i]
  if tmp != zero[i]:
    z += 1
  if tmp != one[i]:
    o += 1
if z < o:
  print(z)
else:
  print(o)

Solution (Python):
s = list(map(int,list(input())))
n = len(s)
s1 = [abs(s[i]-i%2) for i in range(n)]
s2 = [abs(s[i]-(i+1)%2) for i in range(n)]
print(min(sum(s1),sum(s2)))

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

end = ""

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

cnt = 0

for i in range(n):
    if s[i] == end[i]:
        cnt += 1

print(min(cnt, n-cnt))

Solution (Python):

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

for i in range(N):
    if i%2==0:
        if S[i]=="0":
            count2=count2+1
    else:
        if S[i]=="1":
            count2=count2+1
            
print(min(count1,count2))

Solution (Python):




def main():
    n = [int(i) for i in input()]

    ans = list()
    ans.append([i % 2 for i in range(len(n))])
    ans.append([i % 2 for i in range(1, len(n) + 1)])

    a = list()
    for i in ans:
        count = 0
        for j in range(len(n)):
            if i[j] == n[j]:
                count += 1

        a.append(count)

    print(min(a))


if __name__ == '__main__':
    main()

Solution (Python):
s = input()
elements = ["0", "1"]
black_start = [elements[x % 2] for x in range(len(s))]
white_start = [elements[(x+1) % 2] for x in range(len(s))]

ans_white = 0
ans_black = 0
for i in range(len(s)):
    if black_start[i] != s[i]:
        ans_black += 1
    if white_start[i] != s[i]:
        ans_white += 1
print(min(ans_black, ans_white))

Solution (Python):
s = list(map(int, input()))
sod = [s[i] for i in range(len(s)) if i % 2 == 0]
sev = [s[i] for i in range(len(s)) if i % 2 == 1]
sodb = sod.count(0)
sodw = sod.count(1)
sevb = sev.count(0)
sevw = sev.count(1)
print(min([sodb+sevw, sodw+sevb]))

Solution (Python):
s = input()

oddFirst = 0
evenFirst = 0

for i in range(len(s)):
    if i % 2 == 0:
        if int(s[i]) % 2 == 0:
            oddFirst += 1
        else:
            evenFirst += 1
    else:
        if int(s[i]) % 2 == 0:
            evenFirst += 1
        else:
            oddFirst += 1

print(min(oddFirst, evenFirst))

Solution (Python):
s = input()

li = ["0" if i % 2 == 0 else "1" for i in range(len(s))]


count1 = 0
count2 = 0
ans = 0
for i in range(len(s)):
    if s[i] == li[i]:
        count1 += 1
    else:
        count2+= 1

print(min(count1, count2))

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

Solution (Python):
s =input()

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

dif_ol=0
dif_lo=0
for i in range(len(s)):
  if ol[i]!=s[i]:
    dif_ol+=1
  if lo[i]!=s[i]:
    dif_lo+=1

print(min(dif_ol,dif_lo))

Solution (Python):
S = input()
len_S = len(S)
n = len_S // 2
A = "01" * n
if len_S % 2 == 1:
    A += "0"
an, bn = 0, 0
for s, a in zip(S, A):
    if s == a:
        bn += 1
    else:
        an += 1
print(min(an, bn))

Solution (Python):
S = input()
len_S = len(S)
n = len_S // 2
A = "01" * n
B = "10" * n
if len_S % 2 == 1:
    A += "0"
    B += "1"
an, bn = 0, 0
for s, a, b in zip(S, A, B):
    if s == a:
        bn += 1
    else:
        an += 1
print(min(an, bn))

Solution (Python):
s=list(input())
count1=0
count2=0
for i in range(0,len(s),2):
    if s[i]==str(0):
        count1+=1
    if s[i]==str(1):
        count2+=1
for i in range(1,len(s),2):
    if s[i]==str(1):
        count1+=1
    if s[i]==str(0):
        count2+=1
print(min(count1,count2))

Solution (Python):
inf = float('inf')

s = input()

ans = inf
for start_color in '01':
    cost = 0
    for i, ss in enumerate(s):
        if i % 2 == 0:
            if ss != start_color:
                cost += 1
        else:
            if ss == start_color:
                cost += 1
    ans = min(ans, cost)
print(ans)

Solution (Python):
moji_arr = input()

change=0
now_moji = moji_arr[0]

for v in moji_arr[1:]:
    if v==now_moji:
        change += 1
        if v=='0':
            now_moji = '1'
        elif v=='1':
            now_moji = '0'
    else:
        now_moji = v

print(change)