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):


def main(S):
    count=[0,0]
    for i in range(len(S)):
        if i%2==0:
            if S[i]=='0':
                count[0]+=1
            else :
                count[1]+=1
        else :
            if S[i]=='1':
                count[0]+=1
            else :
                count[1]+=1
    print(min(count))

if __name__ == '__main__':
    S = list(input())
    
    main(S)

Solution (Python):
li = [ int(it) for it in input() ]
N = len(li)

s1 = 0
flip = 0
for it in li:
  if it != flip:
    s1+=1
  flip=1-flip
s2 = 0
flip = 1
for it in li:
  if it != flip:
    s2+=1
  flip=1-flip
print ( min (s1,s2) )

Solution (Python):
S = input()
SL = [int(i) for i in S]
SL.append("A")
keepcount = "start"
count = 0
for i in SL:
        if keepcount == "start":
                keepcount = i
        elif keepcount == i:
                keepcount = i^1
                count += 1
        else:
                keepcount = i

print(count)

Solution (Python):
s=list(map(int,list(input())))
so=[]
se=[]
for i in range(len(s)):
    if i%2==0:
        so.append(s[i])
    if i%2!=0:
        se.append(s[i])

tso=sum(so)
tse=sum(se)

if tso>tse:
    print(-(-len(s)//2)-tso+tse)

else:
    print(len(s)//2+tso-tse)

Solution (Python):
s = list(map(int,input()))
e = []
o = []
for i in range(len(s)):
    if i%2==0:
        e.append(0)
    else:
        e.append(1)
for i in range(len(s)):
    if i%2==1:
        o.append(0)
    else:
        o.append(1)
x = 0
y = 0
for i in range(len(s)):
    if s[i]!=e[i]:
        x += 1
    if s[i]!=o[i]:
        y += 1
print(min(x,y))

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

Solution (Python):

s = input()

res1 = 0
res2 = 0
f1 = "0"
f2 = "1"
for c in s:
    if f1!=c:
        res1 += 1
    if f2!=c:
        res2 += 1

    if f1=="0":
        f1 = "1"
    else:
        f1 = "0"
    if f2=="0":
        f2 = "1"
    else:
        f2 = "0"

print(min(res1,res2))

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

target = '0'
cnt = 0
for i in range(len(S)):
  if i == 0:
    target = S[i]
    continue
  if target == S[i]:
    cnt += 1
    if S[i] == '0':
      target = '1'
    else:
      target = '0'
  else:
    target = S[i]
print(cnt)

Solution (Python):
s = input()
odd = s[0::2]
even = s[1::2]

odd0 = odd.count("0")
odd1 = odd.count("1")
even0 = even.count("0")
even1 = even.count("1")

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

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

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


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

print(min(ans1, ans2))

Solution (Python):
s = input()
if len(s) == 1:
    print(0)
else:
    r = 0
    f = s[0]
    for i in s[1:]:
        if i == f:
            r += 1
            f = '1' if i == '0' else '0'
        else:
        	f = i
    print(r)

Solution (Python):
s = input()
b = 0
w = 0
bn = '0'
wn = '1'
for c in s:
    if c != bn:
        b += 1
    if c != wn:
        w += 1
    bn = str(1-int(bn))
    wn = str(1 - int(wn))
print(min(b,w))

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

for i in range(N):
	if S[i] == str(i%2):
		a += 1

print(min(a, N-a))

Solution (Python):
S = input()

if not S[:-1]:
    print(0)
else:

  out1 = out2 = 0
  for i, j in enumerate(S):
    xor = (j == '1') ^ (i % 2)
    out1 += xor

  print(out1 if out1 < (i + 1) - out1 else (i + 1) - out1)

Solution (Python):
S = input()

out1 = out2 = 0
for i, j in enumerate(S):
  xor = (j == '1') ^ (i % 2)
  out1 += xor

print(out1 if out1 < (i + 1) - out1 else (i + 1) - out1)

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

out1 = out2 = 0
for i, j in enumerate(S):
  xor = (j == '1') ^ (i % 2)
  out1 += xor

print(out1 if out1 < l - out1 else l - out1)

Solution (Python):
S = input()

out1 = out2 = 0
for i, j in enumerate(S):
  xor = (j == '1') ^ (i % 2)
  out1 += xor
  out2 += (1 - xor)

print(out1 if out1 < out2 else out2)

Solution (Python):
S = input()

out1, out2 = 0, 0
for i, j in enumerate(S):
  xor = int(j) ^ (i % 2)
  out1 += xor
  out2 += (1 - xor)
  
print(min(out1, out2))

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

seikai1 = [i % 2 for i in range(l)]
seikai2 = [1 ^ i for i in seikai1]

out = min(sum(i ^ int(j) for i, j in zip(seikai1, S)), \
          sum(i ^ int(j) for i, j in zip(seikai2, S)))
print(out)

Solution (Python):





import sys

S = input()




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




ac = 0
bc = 0
for i in range(len(S)):
    if S[i] != a[i]:
        ac += 1
    if S[i] != b[i]:
        bc += 1
print(min(ac, bc))

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

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

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

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

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

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

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

Solution (Python):
S = input()
n =len(S)
y = int()
c = int()
for i in range(n):
	if i % 2 ==0:
		x = "0"
	else:
		x ="1"
	if S[i] == x:
		c += 1
		
	else:
		y += 1
		

if c < y:
	print(c)
else:
	print(y)

Solution (Python):
S = list(input())
a, b = [], []
cnt_a, cnt_b = 0, 0

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

for j in range(len(S)):
    if a[j] != S[j]:
        cnt_a += 1
    if b[j] != S[j]:
        cnt_b += 1

print(min(cnt_a, cnt_b))

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

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

Solution (Python):
s = [int(i) for i in input()]
odd = sum(s[::2])
even = sum(s[1::2])
if odd > even:
    print(even + abs(odd - len(s[::2])))
else:
    print(odd + abs(even - len(s[1::2])))

Solution (Python):
s = input()
x = [s[j] for j in range(0,len(s))]
x.insert(0,'2')
count = 0
for j in range(1,len(x)):
    if x[j] == '0' and x[j] == x[j-1]:
        x[j] = '1'
        count = count + 1
    elif x[j] == '1' and x[j] == x[j-1]:
        x[j] = '0' 
        count = count + 1
print(count)

Solution (Python):
from itertools import zip_longest, islice

S = input()
ans = 0

for curr, next in islice(zip_longest(S, S[1:]), 0, None, 2):
  if curr == '0': ans += 1
  if next == '1': ans += 1

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

Solution (Python):
from itertools import zip_longest

S = input()
ans = 0

for curr, next in list(zip_longest(S, S[1:]))[::2]:
  if curr == '0': ans += 1
  if next == '1': ans += 1

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

Solution (Python):
S = input()

n = len(S)

ans = 0

for i in range(0,n,2):
    if S[i] == '0':
        ans +=1
    if i+1 < n:
        if S[i+1] == '1':
            ans +=1

print(min(ans, n - ans))

Solution (Python):
def diff(s1, s2):
  count = 0
  for (c1, c2) in zip(s1, s2):
    if c1 != c2:
      count += 1
  return count


def main():
  arr = list(input())
  t01 = (['0', '1'] * len(arr))[:len(arr)]
  t10 = (['1', '0'] * len(arr))[:len(arr)]
  print(min(diff(arr, t01), diff(arr, t10)))


if __name__ == "__main__":
  main()

Solution (Python):
tile = input()
ans = 0
for i in range(len(tile) - 1):
  if tile[i+1] != tile[i]:
    continue
  else:
    ans += 1
    if tile[i+1] == "0":
      tile = tile[:i+1] + "1" + tile[i+2:]
    else: 
      tile = tile[:i+1] + "0" + tile[i+2:]
print(ans)

Solution (Python):



def main():
    s = input()
    start_0_invalid = 0
    start_1_invalid = 0
    for i, si in enumerate(s):
        if i % 2 == 0:
            if si == '0':
                start_1_invalid += 1
            else:
                start_0_invalid += 1
        else:
            if si == '0':
                start_0_invalid += 1
            else:
                start_1_invalid += 1
    print(min([start_0_invalid, start_1_invalid]))


if __name__ == '__main__':
    main()

Solution (Python):


N = input()

odd_list = N[0:len(N):2]
even_list = N[1:len(N):2]


def a():
    if len(even_list) == 0:
        print(0)
        return


def calc_one_and_zero(arr):
    zero_count = arr.count('0')
    one_count = arr.count('1')
    return zero_count, one_count


odd_zero,  odd_one = calc_one_and_zero(odd_list)
even_zero, even_one = calc_one_and_zero(even_list)

if odd_zero + even_one > odd_one + even_zero:
    print(odd_one + even_zero)
else:
    print(odd_zero + even_one)

Solution (Python):
S = input()
first = S[0]
inverse = str(1-int(first))
unit = first+inverse
if len(S) % 2 == 0:
  sample = unit*(len(S)//2)
else:
  sample = unit*(len(S)//2)+first

count = 0
for k in range(len(S)):
  if S[k] != sample[k]:
    count += 1

print(count)

Solution (Python):
S = input()
bs = 0
ws = 0
count = 0
for i in range(len(S)):
  s = int(S[i])
  if s != i%2:
    bs += 1
  if s != (i+1)%2:
    ws += 1
print(min(bs,ws))

Solution (Python):
def main(input_str):
    input_list = list(input_str)
    count = 0
    if input_list[0] == "0":
        ans = []
        for i, _ in enumerate(input_list):
            if i % 2 == 0:
                ans.append("0")
            else:
                ans.append("1")
        for i, _ in enumerate(input_list):
            if input_list[i] != ans[i]:
                count += 1

    else:
        ans = []
        for i, _ in enumerate(input_list):
            if i % 2 == 0:
                ans.append("1")
            else:
                ans.append("0")
        for i, _ in enumerate(input_list):
            if input_list[i] != ans[i]:
                count += 1

    return count


if __name__ == "__main__":
    input_str = input()
    print(main(input_str))

Solution (Python):
def main(input_str):
    input_list = list(input_str)
    count = 0
    if input_list[0] == "0":
        ans = []
        for i, _ in enumerate(input_list):
            if i % 2 == 0:
                ans.append("0")
            else:
                ans.append("1")
        for i, _ in enumerate(input_list):
            if input_list[i] != ans[i]:
                count += 1

    else:
        ans = []
        for i, _ in enumerate(input_list):
            if i % 2 == 0:
                ans.append("1")
            else:
                ans.append("0")
        for i, _ in enumerate(input_list):
            if input_list[i] != ans[i]:
                count += 1

    return count


if __name__ == "__main__":
    input_str = input()
    print(main(input_str))

Solution (Python):
s = input()


p1 = 0
p2 = 0

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

if p1 <= p2:
  print(p1)
else:
  print(p2)

Solution (Python):
s = input()
length  = len(s)
s = '0b'+s
s = int(s, 0)

c1 = '0b'+'01'*100000
c1 = int(c1, 0)
c2 = '0b'+'10'*100000
c2 = int(c2, 0)

a1 = bin(s^c1)
a2 = bin(s^c2)

a1 = a1[-length:]
a2 = a2[-length:]

print(min(a1.count('1'),a2.count('1')))

Solution (Python):
S = input()

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




if diff1 > diff2:
    print(diff2)
else:
    print(diff1)

Solution (Python):
BLACK = '0'
WHITE = '1'

original_tile = input()
tile_length = len(original_tile)

bwbw_tile = (BLACK+WHITE) * (tile_length//2)
if tile_length % 2 == 1:
    bwbw_tile += BLACK

repaint_times = 0
for i in range(tile_length):
    if original_tile[i] != bwbw_tile[i]:
        repaint_times += 1

if repaint_times < tile_length - repaint_times:
    print(repaint_times)
else:
    print(tile_length - repaint_times)

Solution (Python):
ss = input()
s1, s2 = [], []
for i, s in enumerate(ss):
  if i % 2 == 0:
    s2.append(int(s))
  else:
    s1.append(int(s))

s1_0, s1_1 = len(s1) - sum(s1), sum(s1)
s2_0, s2_1 = len(s2) - sum(s2), sum(s2)

print(min(s1_0 + s2_1, s1_1 + s2_0))

Solution (Python):

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

if len(s) == 1:
    print(0)
else:
    
    cnt1 = 0
    for idx in range(0, len(s) - 1, 2):
        if s[idx] != 0:
            cnt1 += 1
        if s[idx + 1] != 1:
            cnt1 += 1
    if len(s) % 2 == 1 and s[-1] != 0:
        cnt1 += 1

    
    cnt2 = 0
    for idx in range(0, len(s) - 1, 2):
        if s[idx] != 1:
            cnt2 += 1
        if s[idx + 1] != 0:
            cnt2 += 1
    if len(s) % 2 == 1 and s[-1] != 1:
        cnt2 += 1

    print(min(cnt1, cnt2))

Solution (Python):
s = [int(c) for c in input()]
a = 0
b = 0
for i in range(len(s)):
  if i % 2 == 0 and s[i] == 0:
    a = a
    b = b + 1
  elif i % 2 == 1 and s[i] == 0:
    a = a + 1
    b = b
  elif i % 2 == 0 and s[i] == 1:
    a = a + 1
    b = b
  else:
    a = a
    b = b + 1
p = [a,b]
print(min(p))

Solution (Python):
string = input()
ls = list(map(int, string))

count1, count2 = 0, 0

for i in range(len(ls)):
    ck = (i + 1) % 2
    if ls[i] != ck:
        count1 += 1

for j in range(len(ls)):
    ck = (j + 2) % 2
    if ls[j] != ck:
        count2 += 1

print(min(count1, count2))

Solution (Python):
n=[int(i) for i in input()]
p1=[1 if i%2==0 else 0 for i in range(len(n))]
p2=[0 if i%2==0 else 1 for i in range(len(n))]
p1_n=[p1[i]-n[i] for i in range(len(n))]
ans1=sum(x==0 for x in p1_n)
p2_n=[p2[i]-n[i] for i in range(len(n))]
ans2=sum(x==0 for x in p2_n)
print(min(ans1, ans2))

Solution (Python):

a = input()
result = -500000

privious_list = ["0", "1"]


if len(a) == 1 or 0:
    print(0)
else:
    for x in privious_list:
        new_result = 0
        privious = x
        for i in a:
            if i == "0":
                if privious == "0":
                    new_result += 1
                    privious = "1"
                else:
                    privious = "0"
            else:
                if privious == "0":
                    privious = "1"
                else:
                    new_result += 1
                    privious = "0"
        
        if result == -500000:
            result = new_result
        elif new_result < result:
            result = new_result
    
    if result == -500000:
        result = 0
    print(result)

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

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

Solution (Python):
s = input()
c0 = 0
c1 = 0

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

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

print(min(c0, c1))

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

turn = 0
count_0 = 0
count_1 = 0

for char in S:
    if(turn % 2 == 0):
        if(char == '0'):
            count_0 += 1
        else:
            count_1 += 1
    else:
        if(char == '0'):
            count_1 += 1
        else:
            count_0 += 1
    turn += 1

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

Solution (Python):
import numpy as np
S = input()
S = np.array([int(x) for x in S])

if len(S)%2 == 0:
  P1 = np.array([1, 0]*int(len(S)/2))
  P2 = np.array([0, 1]*int(len(S)/2))
else:
  P1 = np.array([1, 0]*int(len(S)/2) + [1])
  P2 = np.array([0, 1]*int(len(S)/2) + [0])

ans1 = np.abs(S - P1).sum()
ans2 = np.abs(S - P2).sum()

if ans1 < ans2:
  print(ans1)
else:
  print(ans2)

Solution (Python):
S = input()
N = len(S)
from_zero_count = 0
from_one_count = 0
for i in range(N):
  if i%2 == 0 and S[i] == "0":
    from_one_count += 1
  elif i%2 == 0 and S[i] == "1":
    from_zero_count += 1
  elif i%2 == 1 and S[i] == "0":
    from_zero_count += 1
  elif i%2 == 1 and S[i] == "1":
    from_one_count += 1
print(min([from_one_count, from_zero_count]))

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

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

times = min(count, l - count)
print(times)

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

white = []
black = []

for i in range(len(s)):
    if i%2 == 0:
        white.append("1")
        black.append("0")
    else:
        white.append("0")
        black.append("1")
        
for i in range(len(s)):
    if white[i] != s[i]:
        cnt_w += 1
    if black[i] != s[i]:
        cnt_b += 1

print(min(cnt_w, cnt_b))

Solution (Python):
S = input()

le = len(S)
w_pattern = '10'
b_pattern = '01'

A = (w_pattern * int(le/2 + 1))[0:le]
B = (b_pattern * int(le/2 + 1))[0:le]

w_ans = sum([s != a for s,a in zip(S,A)])
b_ans = sum([s != b for s,b in zip(S,B)])
ans = w_ans if w_ans < b_ans else b_ans

print(ans)

Solution (Python):
S = input()

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

Solution (Python):
def getWbStr(length, start):
    clr = ['0', '1']
    cstr = ''
    for i in range(0, length):
        cstr += '0' if i % 2 == start else '1'

    return cstr

s = input()

wstr = getWbStr(len(s), 0)
bstr = getWbStr(len(s), 1)
wcnt, bcnt = 0, 0

for i in range(0, len(s)):
    if s[i] != wstr[i]:
        wcnt += 1
    if s[i] != bstr[i]:
        bcnt += 1

print(min(wcnt, bcnt))

Solution (Python):
def case_1 (S,size):
    count=0
    for i in range(0,size):
        if (i%2==0):
            if(int(S[i])==0):
                count+=1
        else:
            if(int(S[i])==1):
                count+=1
    return count

def case_2 (S,size):
    count=0
    for i in range(0,size):
        if (i%2==1):
            if(int(S[i])==0):
                count+=1
        else:
            if(int(S[i])==1):
                count+=1
    return count

S=str(input())
size=len(S)
can_1=case_1(S,size)
can_2=case_2(S,size)
print(min(can_1,can_2))

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

Solution (Python):
S = input()
back = 0
n = 0
for i in S:
    if i == back:
        back = '0' if i=='1' else '1'
        n += 1
    else:
        back = i

print(n);

Solution (Python):
S=[2*int(s) for s in input()]
N=len(S)
dBW=[S[i]==(1+(-1)**i) for i in range(N)]
dWB=[S[i]==(1-(-1)**i) for i in range(N)]


print(min(sum(dBW),sum(dWB)))

Solution (Python):
s = input()
p = ''
t = 0

def change(x):
    if x == '1':
        return '0'
    else:
        return '1'

for x in s:
    if x == p:
        t += 1
        p = change(x)
    else:
        p = x

print(t)

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

def counter(list):
    b_count = 0
    w_count = 0
    for i in range(len(list)):
        if list[i] == 0 : b_count += 1
        else : w_count += 1
    return b_count,w_count

b_odd , w_odd = counter(odd_i)
b_even , w_even = counter(even_i)

o_diff = b_odd - w_odd
e_diff = b_even - w_even

if o_diff >  e_diff : print(w_odd + b_even)
else : print(b_odd+w_even)

Solution (Python):
s = input()


a1 = s[::2].count("1") + s[1::2].count("0")

a2 = s[::2].count("0") + s[1::2].count("1")

print(min(a1,a2))

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

Solution (Python):
S = str(input())
N = len(S)
d, r = divmod(N, 2)
ref = "01"*d + "0"*r
cnt = 0
for c1, c in zip(ref, S):
    if c1 != c: cnt+=1
print(min(cnt, N-cnt))

Solution (Python):
ss = list(input())
ss = [int(ii) for ii in ss]
nn = len(ss)
bw = list()
wb = list()
while True:
    if len(bw)+2<=nn:
        bw.append(0)
        bw.append(1)
        wb.append(1)
        wb.append(0)
        continue
    elif len(bw)+1==nn:
        bw.append(0)
        wb.append(1)
        continue
    else:
        break

counter_bw = 0
counter_wb = 0
for ii in range(nn):
    if ss[ii] == bw[ii]:
        counter_bw += 1
    if ss[ii] == wb[ii]:
        counter_wb += 1

answer = min(counter_bw, counter_wb)
print(answer)

Solution (Python):
S = [int(c) for c in input()]
black_started = [0 ^ (i % 2) for i in range(len(S))]
white_started = [1 ^ (i % 2) for i in range(len(S))]
black_diff = 0
white_diff = 0
for i in range(len(S)):
    if black_started[i] != S[i]:
        black_diff += 1
    if white_started[i] != S[i]:
        white_diff += 1
print(min(black_diff, white_diff))

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

Solution (Python):
S = input()

start_0 = 0
start_1 = 0

for i, S_i in enumerate(S):
    
    if i % 2 == 0:
        if S_i == "0":
            start_1 += 1
            
        else:
            start_0 += 1
            
    else:
        if S_i == "0":
            start_0 += 1
            
        else:
            start_1 += 1
            

print(min(start_0, start_1))

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

    
apopcount=0
bpopcount=0
for i in range(0,l):
  if i%2==0:
    if int(S[i])==1:
   		apopcount+=1
    else:
      	bpopcount+=1
  else:
    if int(S[i])==1:
    	bpopcount+=1
    else:
      	apopcount+=1
if apopcount<bpopcount:print(apopcount)
else:print(bpopcount)

Solution (Python):
a  = input()
s = 0
t = 0
k = ["0","1"]
for n,i in enumerate(a):
  if i != k[(n%2)]:
    s+=1
  if i != k[(n+1)%2]:
    t+=1
print(min(s,t))

Solution (Python):
S = input()
bw = 0
wb = 0
for i in range(len(S)):
    if int(S[i]) == i % 2:
        wb += 1
    else:
        bw += 1

print(min(bw, wb))

Solution (Python):

s = input()
bins = [b == '1' for b in s]

pattern_a = ([True, False] * ((len(s) // 2) + 1))[:len(s)]
pattern_b = ([False, True] * ((len(s) // 2) + 1))[:len(s)]

pat_a_min = [p ^ q for p, q in zip(bins, pattern_a)].count(True)
pat_b_min = [p ^ q for p, q in zip(bins, pattern_b)].count(True)

print(min(pat_a_min, pat_b_min))

Solution (Python):
from sys import stdin

S = [int(x) for x in list(stdin.readline().rstrip())]

even = len(S) // 2
odd = len(S) // 2 + (len(S) % 2)

evens = 0
odds = 0

for i in S[1::2]:
    evens += i

for i in S[::2]:
    odds += i

print(min(even - evens + odds, odd - odds + evens))

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

even_list = list()
odd_list = list()

even_list = n[0::2]
odd_list = n[1::2]

count_zero = 0
count_one = 0


for i in range(len(even_list)):
    if even_list[i] == 1:
        count_zero += 1
for j in range(len(odd_list)):
    if odd_list[j] == 0:
        count_zero += 1

for n in range(len(even_list)):
    if even_list[n] == 0:
        count_one += 1
for m in range(len(odd_list)):
    if odd_list[m] == 1:
        count_one += 1

print(min(count_zero, count_one))

Solution (Python):

str_S = input()
len_S = len(str_S)
num_S = int(str_S, 2)
mask = 0B0

for i in range(len_S):
    mask = mask << 1
    if i % 2 == 0:
        mask += 1

cnt_one = bin(mask ^ num_S).count("1")

print(min(cnt_one, len_S - cnt_one))

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

import copy
s1 = copy.copy(s)
s2 = copy.copy(s)

cnt1,cnt2 = 1, 0

if s1[0] == 0:
    s1[0] = 1
else:
    s1[0] = 0
for i in range(1,l):
    if s1[i - 1] == s1[i]:
        cnt1 += 1
        if s1[i - 1] == 1:
            s1[i] = 0
        else:
            s1[i] = 1

for j in range(1,l):
    if s2[j - 1] == s2[j]:
        cnt2 += 1
        if s2[j - 1] == 1:
            s2[j] = 0
        else:
            s2[j] = 1

print(min(cnt1,cnt2))

Solution (Python):


s = input()
n = len(s)
m = n // 2

if n%2 == 0:
    x = '01'*m
    y = '10'*m
else:
    x = '01'*m + '0'
    y = '10'*m + '1'

l = [0,0]
for i in range(n):
    if s[i] != x[i]:
        l[0] += 1
    if s[i] != y[i]:
        l[1] += 1

print(min(l))

Solution (Python):
s = input()

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

print(min(count1, count2))

Solution (Python):
s = input()

s_odd = s[::2]
s_even = s[1::2]

ans = min(s_odd.count("1")+s_even.count("0"),s_odd.count("0")+s_even.count("1"))

print(ans)

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

Solution (Python):


from sys import stdin
import numpy as np

s = input()
a = [int(c) for c in s]


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

Solution (Python):

s = input()


n = len(s)



a = [0 for i in range(n)]
b = [0 for i in range(n)]

if s[0] == '0':
	a[0] = 1
	b[0] = 0
else:
  a[0] = 0
  b[0] = 1

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

print(min(a[n-1], b[n-1]))

Solution (Python):
S=list(input())
N=len(S)
A=[]
B=[]
for i in range(N):
    A.append(str(i%2))
    B.append(str((i+1)%2))
countA=0
countB=0
for x in range(N):
    if A[x]!=S[x]:
        countA+=1
    else:
        countB+=1

print(min(countA,countB))

Solution (Python):
S=str(input())
sl=S[::2]
sr=S[1::2]
N=len(S)
n1=len(sl)
n2=len(sr)
num1=sl.count('0')
num2=sr.count('0')
ans1=num1+n2-num2
ans2=num2+n1-num1
a=min(ans1,ans2)
print(a)

Solution (Python):
s = input()




a = s[::2].count('1')
b = s[1::2].count('0')
c = s[::2].count('0')
d = s[1::2].count('1')






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

Solution (Python):
n = input()

black = 0
white = 0

for i in range(len(n)):

    if i % 2 == 0:
        if n[i] == "0":
            white += 1
        else:
            black += 1

    else:
        if n[i] == "0":
            black += 1
        else:
            white += 1

if black <= white:
    print(black)
else:
    print(white)

Solution (Python):
S=[int(x) for x in list(str(input()))]
ds={0:1,1:0}
count=0
for i in range(1,len(S)):
    if S[i]==S[i-1]:
        S[i]=ds[S[i]]
        count=count+1
        
print(count)

Solution (Python):
s = [int(i) for i in list(input())]
n = len(s)
patA = [i % 2 for i in range(n)]
patB = [i % 2 for i in range(1,n+1)]
diffA = [0]*n
diffB = [0]*n
for i in range(n):
  diffA[i] = s[i] - patA[i]
  diffB[i] = s[i] - patB[i]
ans = [0,0]
ans[0] = len([i for i in diffA if i == 0])
ans[1] = len([i for i in diffB if i == 0])
print(min(ans))

Solution (Python):
S = list(input())
 
count = 0
s1 = S[:]
for i in range(1, len(S)):
    if s1[i - 1] == s1[i]:
        s1[i] = '0' if s1[i-1] == '1' else '1'
        count += 1
 
count2 = 0
s2 = S[:]
for i in reversed(range(len(S)-1)):
    if s2[i] == s2[i +1]:
        s2[i] = '0' if s2[i+1] == '1' else '1'
        count2 += 1
 
print(min(count, count2))

Solution (Python):

S=str(input())
N=len(S)
str1=''
str2=''
for n in range(N//2):
    str1=str1+'01'
    str2=str2+'10'
if N%2:
    str1=str1+'0'
    str2=str2+'1'
min1=sum(str1[i]!=S[i] for i in range(N))
min2=sum(str2[i]!=S[i] for i in range(N))
print(min(min1,min2))

Solution (Python):
s = [int(i) for i in input()]
n = len(s)

l = sum(s[0::2])
r = sum(s[1::2])

print(min(abs(l-r+len(s[1::2])), abs(r-l+len(s[0::2]))))

Solution (Python):
s = input()

odd = s[::2]
even = s[1::2]
ans = odd.count("0") + even.count("1")
ans = min(ans, len(s) - ans)
print(ans)

Solution (Python):
s=input()

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

print(min(ans))

Solution (Python):
S = input()

N = len(S)

S2 = S



count_1 = 0
count_2 = 0
for i in range(N):
	if i % 2 == 0:
		if S[i] == '1':
			count_1 += 1
		else:
			count_2 += 1
	else:
		if S[i] == '0':
			count_1 += 1
		else:
			count_2 += 1

print (min(count_1,count_2))

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

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

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

Solution (Python):
S = list(input())
S = [int(s) for s in S]
T = []
for s in range(len(S)):
    if s % 2 == 0:
        T.append(S[s]==0)
    else:
        T.append(S[s]==1)
U = []
for s in range(len(S)):
    if s % 2 == 0:
        U.append(S[s]==1)
    else:
        U.append(S[s]==0)
M = max(sum(T), sum(U))
print(len(S)-M)