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 = list(input())
t = list(reversed(s))
ans1 = 0
for i in range(len(s)-1):
  if s[i]==s[i+1]=="0":
    s[i+1] ="1"
    ans1+=1
  elif s[i]==s[i+1]=="1":
    s[i+1] ="0"
    ans1+=1
ans2 = 0
for i in range(len(t)-1):
  if t[i]==t[i+1]=="0":
    t[i+1] ="1"
    ans2+=1
  elif t[i]==t[i+1]=="1":
    t[i+1] ="0"
    ans2+=1
print(min(ans1, ans2))

Solution (Python):
s = input()
Aans = 0
Bans = 0
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)

for i in range(len(s)):
    if int(s[i]) != A[i] :
        Aans += 1
    elif int(s[i]) != B[i] :
        Bans += 1
print(min(Aans,Bans))

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

Solution (Python):
s = input()
a = 0
b = 0
for i in range(len(s)):
    if i%2 == 0:
        a += 2**i
    else:
        b += 2**i
s = int(s, 2)
print(min(bin(a^s).count('1'), bin(b^s).count('1')))

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


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

Solution (Python):
s = list(input())
for i in range(len(s)):
  s[i] = int(s[i])
c = 0
for i in range(1,len(s)):
  if s[i-1] == s[i]:
    s[i] += 1
    s[i] %= 2
    c += 1
if c > len(s) // 2:
  print(len(s)-c)
else:
  print(c)

Solution (Python):

count=0
s=list(input())
x=int(s[0])
for i in range(len(s)):
    if s[i]!=str(x):
        count+=1
    x=(x+1)%2
print(count)
exit()

Solution (Python):
S=input()
N=len(S)
tile=['0' if i&1==0 else '1' for i in range(N)]
ans=0
for i in range(N):
  if S[i]!=tile[i]:
    ans+=1
print(ans if ans<=N//2 else N-ans)

Solution (Python):
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """000"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """10010010"""
        output = """3"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """0"""
        output = """0"""
        self.assertIO(input, output)
def resolve():
    S=[int(i) for i in input()]
    X=sum([1 if i%2 != S[i] else 0 for i in range(len(S))])
    Y=sum([1 if S[i] != (i+1)%2 else 0 for i in range(len(S))])
    print(min(X,Y))
if __name__ == "__main__":
    resolve()

Solution (Python):
def f_c():
    s = input()
    co, ce = 0, 0
    for i in range(len(s)):
        if i%2!=0:
            co = co+1 if s[i]!="1" else co
            ce = ce+1 if s[i]!="0" else ce
        else:
            co = co+1 if s[i]!="0" else co
            ce = ce+1 if s[i]!="1" else ce
    print(min(co, ce))

if __name__ == "__main__":
    f_c()

Solution (Python):
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
S=input()

a=[S[::2].count(l) for l in "01"]
b=[S[1:][::2].count(k) for k in "01"]

print(min(a[0]+b[1],a[1]+b[0]))

Solution (Python):
S = input()

size = len(S)
n = "".join("1" if i % 2 == 0 else "0" for i in range(size))

nc, mc = 0, 0
for i in range(size):
    if S[i] == n[i]:
        nc += 1
    else:
        mc += 1

print(min(nc, mc))

Solution (Python):

s=input()
n=len(s)
count1=0
for i in range(n):
    if i%2==0:
        if s[i]=="1":
            count1+=1
    else:
        if s[i]=="0":
            count1+=1
count2=0
for i in range(n):
    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()
l = len(s)
counter = 0
if s[0] == '1':
    for i in range(1, l):
        if i % 2 == 1 and s[i] == '1':
            counter += 1
        elif i % 2 == 0 and s[i] == '0':
            counter += 1
else:
    for i in range(1, l):
        if i % 2 == 1 and s[i] == '0':
            counter += 1
        elif i % 2 == 0 and s[i] == '1':
            counter += 1
print(counter)

Solution (Python):
S = input()


tmp=0
cntA=0
for i in range(len(S)):
    if tmp!=int(S[i]):
        cntA+=1
    if tmp==0:
        tmp=1
    else:
        tmp=0


tmp=1
cntB=0
for i in range(len(S)):
    if tmp!=int(S[i]):
        cntB+=1
    if tmp==0:
        tmp=1
    else:
        tmp=0

print(min(cntA,cntB))

Solution (Python):
s1=[1,0]*5*10**4
s0=[0,1]*5*10**4
s=list(input())
a1,a0=0,0
for i in range(len(s)):
    a1+=abs(int(s[i])-s1[i])
    a0+=abs(int(s[i])-s0[i])
print(min(a0,a1))

Solution (Python):
s = list(map(int, list(input())))
zero_begin = 0
one_begin = 0
for i in range(len(s)):
  if(i % 2 == 0):
    if(s[i] == 0):
      one_begin += 1
    else:
      zero_begin += 1
  else:
    if(s[i] == 0):
      zero_begin += 1
    else:
      one_begin += 1
print(min([zero_begin, one_begin]))

Solution (Python):
s=input()
list=[]
lhst=[]
for i in range(len(s)):
  list.append(0)
  lhst.append(0)
for j in range(len(s)):
  if j%2==0:
    list[j]=1
  else:
    lhst[j]=1
d=0
e=0
for l in range(len(s)):
  f=int(s[l])
  if list[l]==f:
    d+=1
  else:
    e+=1
print(min(d,e))

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

Solution (Python):
S = input()
tmp1 = '01' * (len(S) // 2 + 1)
tmp2 = '10' * (len(S) // 2 + 1)
C = {0 : 0, 1 : 0}
for i, s in enumerate(S):
    if s != tmp1[i] : C[0] += 1
    if s != tmp2[i] : C[1] += 1
print(min(C.values()))

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

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

c=0
for i, s in enumerate(S):
  c += (ord(s) - ord('0')) ^ (i % 2)
print(min(c, len(S) - c))

Solution (Python):
n=input()
s=""
a=""
sd,ad=0,0
for i in range(len(n)):
  if i%2:
    s+="1"
    a+="0"
  else:
    s+="0"
    a+="1"
for i in range(len(n)):
  if n[i]!=a[i]:ad+=1
  if n[i]!=s[i]:sd+=1
print(min(ad,sd))

Solution (Python):
S=str(input())
right_str = S[0]

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

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

Solution (Python):
s = input()
res = 0
rez = 0
if len(s) %2 ==0:
    hs = len(s) // 2
    for i in range(0,hs):
        if s[2*i] == "0":
            res += 1
        else:
            rez += 1
        if s[2*i+1] =="1":
            res += 1
        else:
            rez += 1
else:
    hs = len(s) // 2
    if s[0] == "0":
        res += 1
    else:
        rez += 1
    for i in range(0,hs):
        if s[2*i+2] == "0":
            res += 1
        else:
            rez += 1
        if s[2*i+1] =="1":
            res += 1
        else:
            rez += 1


print(min(res,rez))

Solution (Python):
s = input()
From0 = False
From1 = True
cntF0 = 0
cntF1 = 0
for i in range(len(s)):
    if s[i]!=str(int(From0)):
        cntF0 +=1
    if s[i]!=str(int(From1)):
        cntF1 +=1
    From0 = not(From0)
    From1 = not(From1)
print(min(cntF0,cntF1))

Solution (Python):
S = input()

start_0_count = 0
for i in range(len(S)):
    if i%2 == 0 and S[i] != "0":
        start_0_count += 1
    elif i%2 == 1 and S[i] != "1":
        start_0_count += 1
    else:
        pass
    
start_1_count = 0
for i in range(len(S)):
    if i%2 == 0 and S[i] != "1":
        start_1_count += 1
    elif i%2 == 1 and S[i] != "0":
        start_1_count += 1
    else:
        pass

print(min(start_0_count, start_1_count))

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

count = 0
ans = 0
for i in range(n):
	if i % 2 == 0 and target1[i] == "1":
		count += 1
	elif i % 2 and target1[i] == "0":
		count += 1
	
	if i % 2 == 0 and target2[i] == "0":
		ans += 1
	elif i % 2 and target2[i] == "1":
		ans += 1
		
print(min(count, ans))

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

Solution (Python):
s = input()
n = len(s)
count10 = 0
count01 = 0
if s[0] == '1':
    for i in range(1, n):
        if i%2 != 0:
            if s[i] == '1':
                count10 += 1
        else:
            if s[i] == '0':
                count10 += 1
if s[0] == '0':
    for i in range(1, n):
        if i%2 != 0:
            if s[i] == '0':
                count01 += 1
        else:
            if s[i] == '1':
                count01 += 1
print(max(count01, count10))

Solution (Python):
S = input()
n = len(S)
a = b = ''
for i in range(n):
    if i % 2 == 0:
        a += '0'
        b += '1'
    else:
        a += '1'
        b += '0'

diff_a = diff_b = 0
for i in range(n):
    if S[i] != a[i]:
        diff_a += 1
    if S[i] != b[i]:
        diff_b += 1

print(min(diff_a, diff_b))

Solution (Python):
s = input()
n = len(s)
z0 = 0
z1 = 0
for i in range(n):
  if int(s[i]) ^ (i%2) == 0:
    z0 += 1
  else:
    z1 += 1
print(min(z0,z1))

Solution (Python):
s = input()

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

print(min(bin(int(s, 2) ^ int(a, 2)).count("1"), bin(int(s, 2) ^ int(b, 2)).count("1")))

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

cnt_1 = 0
cnt_2 = 0


for i in range(n):
  if i % 2 != int(s[i]):
    cnt_1 += 1


for i in range(n):
  if i % 2 == int(s[i]):
    cnt_2 += 1
      
print(min(cnt_1, cnt_2))

Solution (Python):

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

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

Solution (Python):
lst = list(input())
p = -1
ans = 0
s = set(['0','1'])
for e in lst:
    if e == p:
        ans += 1
        p = (s - set(e)).pop()
    else:
        p = e
print(ans)

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

Solution (Python):

def swap(ch):
    if ch == '0':
        return '1'
    else:
        return '0'


s = list(input())
ct = 0

for i in range(len(s)-1):
    if s[i] == s[i+1]:
        s[i+1] = swap(s[i+1])
        ct += 1

print(ct)

Solution (Python):
S = input()

def paint(str_num, S):
    cnt = 0
    temp = int(str_num)
    for i in range(len(S)):
        if int(S[-1-i]) == temp:
            temp = (temp+1)%2
        else:
            cnt += 1
            temp = (temp+1)%2
    return cnt
            
print(min(paint("0", S),paint("1", S)))

Solution (Python):
S = input()
N = len(S)
V = []
for i in range(N):
    V.append(int(S[i]))

A = []
B = []
for i in range(N):
    if i%2 == 0:
        A.append(0)
        B.append(1)
    else:
        A.append(1)
        B.append(0)

def count_dif(X,Y):
    p = 0
    for i in range(len(X)):
        if X[i] != Y[i]:
            p += 1
    return(p)

print(min(count_dif(V,A), count_dif(V,B)))

Solution (Python):
S = input()

tmp1 = 0
f = '0'
for s in S:
    if s != f:
        tmp1 += 1
    if f == '0':
        f = '1'
    else:
        f = '0'
tmp2 = 0
f = '1'
for s in S:
    if s != f:
        tmp2 += 1
    if f == '0':
        f = '1'
    else:
        f = '0'
print(min(tmp1, tmp2))

Solution (Python):
def main():
    s = list(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
    t = 0
    for i in range(len(s)):
        if i % 2 == 0:
            if s[i] == "1":
                t += 1
        else:
            if s[i] == "0":
                t += 1
    print(min(ans , t))



if __name__ == '__main__':
    main()

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

Solution (Python):
s=list(input())
if(len(s)==1):
    print(0)
else:
    a=s[:]
    fir,sec=0,0
    for i in range(len(s)-1):
        if(s[i]==s[i+1]):
            s[i+1] = str(1 - (ord(s[i])-48))
            fir+=1
    print(fir)

Solution (Python):
s=list(input())
if(len(s)==1):
    print(0)
else:
    a=s[:]
    fir,sec=0,0
    for i in range(len(s)-1):
        if(s[i]==s[i+1]):
            s[i+1] = str(1 - (ord(s[i])-48))
            fir+=1
    for i in range(len(s)-1,0,-1):
        if(a[i]==a[i-1]):
            a[i-1] = str(1 - (ord(a[i])-48))
            sec+=1
    print(min(fir,sec))

Solution (Python):
S = input()

zero_start_cnt = 0
one_start_cnt = 0

for i in range(len(S)):
    if i % 2 == 0:
        zero_color = '0'
        one_color = '1'
    else:
        zero_color = '1'
        one_color = '0'

    if S[i] != one_color:
        one_start_cnt += 1
    else:
        zero_start_cnt += 1

print(min(one_start_cnt, zero_start_cnt))

Solution (Python):
a=input()

if len(a)==1:
  print(0)
  exit()
  
b=a[::2]
c=a[1::2]

b0=b.count("0")
b1=b.count("1")
c0=c.count("0")
c1=c.count("1")

print(min(b0+c1,b1+c0))

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


if __name__ == "__main__":
    test()

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


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



count = 0
before = 0
for i in range(len(S)):
    if S[i] == before:
        count += 1
    before ^= 1

ans = count

count = 0
before = 1
for i in range(len(S)):
    if S[i] == before:
        count += 1
    before ^= 1

ans = min(ans, count)

print(ans)

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

Solution (Python):
S = list(input())
even_list = S[::2]
odd_list =  S[1::2]

even_black = even_list.count('0')
even_white = even_list.count('1')
odd_black = odd_list.count('0')
odd_white = odd_list.count('1')

if even_white + odd_black < even_black + odd_white:
    print(even_white + odd_black)
else:
    print(even_black + odd_white)

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


kaishi0=0
for i in range(n):
  kaishi0+=abs(int(s[i])-i%2)


kaishi1=0
for i in range(n):
  kaishi1+=abs(int(s[i])-((i+1)%2))

print(min(kaishi0,kaishi1))

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

S1=[i%2 for i in range(N)]
S2=[(i+1)%2 for i in range(N)]

counter1=0
for i in range(N):
  if S[i]!=S1[i]:
    counter1+=1
    
counter2=0
for i in range(N):
  if S[i]!=S2[i]:
    counter2+=1
    
print(min(counter1, counter2))

Solution (Python):
string = input()
n  = len(string)
a  = '10'*(n//2+1)
b  = '01'*(n//2+1)
a = a[:n]
b = b[:n]

x = int(a,2) ^ int(string,2)
y = int(b,2) ^ int(string,2)
l ="{0:b}".format(x)
k ="{0:b}".format(y)

print(min(l.count('1'),k.count('1')))

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

count1=0
count2=0

for i in range(0,len(S),2):
    if S[i] == '0':
        count1 +=1
    else:
        count2 +=1
    

    
for j in range(1,len(S),2):
    if S[j] == '1':
        count1 +=1
    else:
        count2 +=1

if count2 >= count1:
    print(count1)
else:
    print(count2)

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

cnt = 0
for i, s in enumerate(S):
    if i % 2 == 0 and s != "1":
        cnt += 1
    elif i % 2 == 1 and s != "0":
        cnt += 1

cnt1 = 0
for i, s in enumerate(S):
    if i % 2 == 0 and s != "0":
        cnt1 += 1
    elif i % 2 == 1 and s != "1":
        cnt1 += 1

print(min(cnt, cnt1))

Solution (Python):
S=str(input())
s=len(S)
Sk=[]
Sg=[]
for i in range(0,s,2):
    Sk.append(S[i])
for i in range(1,s,2):
    Sg.append(S[i])
Sk0=Sk.count('0')
Sk1=Sk.count('1')
Sg0=Sg.count('0')
Sg1=Sg.count('1')
Stotal=[Sk0,Sk1,Sg0,Sg1]
if Sk0+Sg1<Sk1+Sg0:
    print(Sk0+Sg1)
else:
    print(Sk1+Sg0)

Solution (Python):
S=input()

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

ans=len(S)-temp

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

ans=min(ans,len(S)-temp)

print(ans)

Solution (Python):
s = list(int(x) for x in input())
n = len(s)
ans = []

count = 0
if n >= 3:
  if s[0] == s[1]:
    count += 1
for i in range(2, n):
  if i%2 == 0 and s[i] != s[0]:
    count += 1
  elif i%2 == 1 and s[i] == s[0]:
    count += 1
ans.append(count)

count = 1
if n >= 3:
  if s[0] != s[1]:
    count += 1
for i in range(2, n):
  if i%2 == 0 and s[i] == s[0]:
    count += 1
  elif i%2 == 1 and s[i] != s[0]:
    count += 1
ans.append(count)

if n == 1:
  print(0)
elif n == 2:
  if s[0] == s[1]:
    print(1)
  else:
    print(0)
else:
  print(min(ans))

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

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

cnt1 = 0
cnt2 = 0
for i in range(len(s)):
  if s[i] != t1[i]:
    cnt1 += 1
  if s[i] != t2[i]:
    cnt2 += 1
    
print(min(cnt1,cnt2))

Solution (Python):
S = list(map(int, list(input())))
same = 0
for i in range(len(S)):
    if (i%2==0 and S[i]==0) or (i%2==1 and S[i]==1):
        same += 1
print(min(same, len(S)-same))

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

Solution (Python):
S=input()

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

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

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

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

Solution (Python):
import copy

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

T = copy.copy(S)

ans1 = 0
ans2 = 0

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

T[0] = 1 ^ T[0]
ans2 += 1
for i in range(N-1):
    if T[i] == T[i+1]:
        T[i+1] = 1 ^ T[i+1]
        ans2 += 1
        

ans = min(ans1, ans2)
print(ans)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


s = S()


str1 = '10' * (len(s) // 2) + (len(s) % 2) * '1'
str2 = '01' * (len(s) // 2) + (len(s) % 2) * '0'



cnt1 = 0

for i in range(len(s)):
    if s[i] != str1[i]:
        cnt1 += 1


cnt2 = 0
for i in range(len(s)):
    if s[i] != str2[i]:
        cnt2 += 1



print(min(cnt1, cnt2))

Solution (Python):
s = input()

s1 = ''.join(['1' if i%2 == 0 else '0' for i in range(len(s))])
s2 = ''.join(['0' if i%2 == 0 else '1' for i in range(len(s))])

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

Solution (Python):
S = list(input())
S = list(map(int,S))
N = len(S)
S1 = []
S2 = []
for i in range(N):
    if i%2==0:
        S1.append(0)
        S2.append(1)
    else:
        S1.append(1)
        S2.append(0)
d1 = 0
d2 = 0
for i in range(N):
    d1 += (S[i]+S1[i])%2
    d2 += (S[i]+S2[i])%2
print(min(d1,d2))

Solution (Python):
s = input()

cand1, cand2 = "", ""
if len(s) % 2 == 0:
  cand1 = "10" * (len(s) // 2)
  cand2 = "01" * (len(s) // 2)
else:
  cand1 = "0" + "10" * ((len(s) - 1) // 2)
  cand2 = "1" + "01" * ((len(s) - 1) // 2)

counter_cand1 = [s[i] == cand1[i] for i in range(len(s))]
counter_cand2 = [s[i] == cand2[i] for i in range(len(s))]

print(min(counter_cand1.count(False), counter_cand2.count(False)))

Solution (Python):
S = input()

As = []
Bs = []
count = 0
a = False
for i in range(len(S) - 1):
    count += 1
    if S[i] == S[i+1]:
        if a:
            As.append(count)
        else:
            Bs.append(count)
        a = not a
        count = 0
count += 1
if a:
    As.append(count)
else:
    Bs.append(count)

ans = sum(As) if sum(As) < sum(Bs) else sum(Bs)

print(ans)

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

p1 = ['0' if i % 2 == 0 else '1' for i in range(len(S))]
p2 = ['0' if i % 2 == 0 else '1' for i in range(1, len(S) + 1)]

d1, d2 = 0, 0
for k in range(len(S)):
    if S[k] == p1[k]:
        d1 += 1
    if S[k] == p2[k]:
        d2 += 1

res = min(d1, d2)
print(res)

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

for i in range(len(s)):
  if i%2==0 and s[i]=="1":
    B +=1
  if i%2!=0 and s[i]!="1":
    B +=1
    
print(min(W,B))

Solution (Python):
def change(a):
    if a == 0:
        return 1
    if a == 1:
        return 0

s = list(map(int,input()))
ans = 0
if len(s) == 0:
    print(0)
else:
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            s[i+1] = change(s[i+1])
            ans += 1
print(ans)

Solution (Python):
a = input("")
b = list(a)
j = 0;
k = 0;
for m in b:
    if int(m) == 0 or int(m) == 1:
        k = k+1;
if k == len(b):
    if (int(b[0])==1 or int(b[0])==0) and len(b) == 1:
        j = 0
    else:
        for i in range(len(b)-1):
            if(b[i]==b[i+1]):
                if int(b[i]) == 0:
                    b[i+1] = "1"
                else:
                    b[i+1] = "0"
                j = j + 1;
            
print(j)

Solution (Python):
S=input()

def count(color_num,S):
    ans=0
    for i in range(len(S)):
        if i%2==0 and S[i]!=color_num:
            ans+=1
        elif i%2==1 and S[i]==color_num:
            ans+=1
    return ans

case_w=count('1',S)
case_b=count('0',S)

print(min(case_b,case_w))

Solution (Python):
x = list(str(input()))
i = 0
counter =0
while i<len(x)-1 :
    if(x[i]==x[i+1]):
        if x[i+1]=="0":
            x[i+1]="1"
        else:
            x[i+1]="0"
       
        counter+=1
    i+=1
print(counter)

Solution (Python):
x=input()
x=[i for i in x]
n=len(x)
y=['1']
a=0
b=0
for i in range(n-1):
    if i%2==0:
        y.append('0')
    else:
        y.append('1')
z=['0']
for i in range(n-1):
    if i%2==0:
        z.append('1')
    else:
        z.append('0')
for i in range(n):
    if x[i]!=y[i]:
        a+=1
    if x[i]!=z[i]:
        b+=1
print(min(a,b))

Solution (Python):
c = input()
sum = 0;
cc = c[0]
if len(c)!=1:
    for i in range(1,len(c)):
        if (c[i]==cc[i-1]):
            sum+=1
            if (c[i]=='1'):
                cc+='0'
            else:
                cc+='1'
        else:
            cc+=c[i]
print(sum)

Solution (Python):
N = input()
S = [int(c) for c in N]

A = [0] * (len(S)+4)
B = [0] * (len(S)+4)

for i in range((len(S)//2)+1):
  A[i*2+1] = 1
  B[i*2] = 1
  
ca =0
cb =0
for i in range(len(S)):
  ca += abs(S[i]-A[i])
  cb += abs(S[i]-B[i])
print(min(ca, cb))

Solution (Python):
s=input()

BW=s[::2]
WB=s[1::2]

x=BW.count("0") + WB.count("1")
y=BW.count("1") + WB.count("0")

print(min(x,y))

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

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

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

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

Solution (Python):
S = input()
d,m = len(S)//2,len(S)%2
A = '01'*d+'0'*m
B = '10'*d+'1'*m
count_a = 0
count_b = 0
for s,a,b in zip(S,A,B):
    if s != a:
        count_a += 1
    if s != b:
        count_b += 1
print(min(count_a, count_b))

Solution (Python):
S = input()
d,m = len(S)//2,len(S)%2
A = '01'*d+'0'*m
B = '10'*d+'1'*m
count_a = 0
count_b = 0
for s,a,b in zip(S,A,B):
    if s != a:
        count_a += 1
    if s != b:
        count_b += 1
print(min(count_a, count_b))

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

a = []
b = []
counta = 0
countb = 0
for i in range(n):
    if i % 2 == 0:
        a.append("0")
        b.append("1")
    else:
        a.append("1")
        b.append("0")
    if s[i] != a[i]:
        counta += 1
    if s[i] != b[i]:
        countb += 1
print(min(counta,countb))

Solution (Python):
S=input()

one_start=["1","0"]
one_start_count=0

zero_start=["0","1"]
zero_start_count=0

for i,subs in enumerate(S):
    if subs !=one_start[i%2]:
        one_start_count+=1
    elif subs != zero_start[i%2]:
        zero_start_count+=1
        

print(min(one_start_count, zero_start_count))

Solution (Python):
if __name__ == '__main__':
    S = str(input())
    
    N = len(S)
    S_0 = '01'*N
    S_0 = S_0[:N]
    S_1 = '10'*N
    S_1 = S_1[:N]
    
    count_0 = 0
    count_1 = 0
    for i in range(N):
        if S[i] != S_0[i]:
            count_0 += 1
        if S[i] != S_1[i]:
            count_1 += 1
    print(min(count_0, count_1))

Solution (Python):
s = input()

targets = []
if len(s) % 2 == 0:
    tmp_1 = ''
    tmp_2 = ''
    for i in range(len(s)//2):
        tmp_1 += '10'
        tmp_2 += '01'
    targets.append(tmp_1)
    targets.append(tmp_2)
else:
    tmp_1 = ''
    tmp_2 = ''
    for i in range(len(s)//2):
        tmp_1 += '10'
        tmp_2 += '01'
    tmp_1 += '1'
    tmp_2 += '0'
    targets.append(tmp_1)
    targets.append(tmp_2)

res = len(s)
for target in targets:
    count = 0
    for i in range(len(target)):
        if target[i] != s[i]:
            count += 1
    res = min(res, count)

print(res)

Solution (Python):
S=input()
l=len(S)
A='01'*(l//2)+'0'*(l%2)
c=0
for i in range(l):
  if A[i]==S[i]:c+=1
print(min(c,l-c))

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

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

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

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

Solution (Python):
import numpy as np

S = list(int(x) for x in input())

L1 = np.array([0 if x % 2 == 0 else 1 for x in range(len(S))] )
L2 = np.array([1 if x % 2 == 0 else 0 for x in range(len(S))])

print(min(sum(np.logical_xor(S, L2)), sum(np.logical_xor(S, L1))))

Solution (Python):
s = input()
c = 0

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "0":
            c += 1
    else:
        if s[i] == "1":
            c += 1
if len(s) - c < c:
    c = len(s) - c
print(c)

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    s = str(input().rstrip('\n'))
    b = 0
    cnt1 = 0
    cnt2 = 0
    for i in range(len(s)):
        if b == int(s[i]):
            cnt1 += 1
        if b != int(s[i]):
            cnt2 += 1
        b = 1 if b == 0 else 0
    print(min(cnt1, cnt2))


if __name__ == '__main__':
    slove()

Solution (Python):
s = input().strip()
cs = list(map(int, list(s)))
n = len(cs)

a = [0 for _ in range(n)]
for i in range(n):
    if i % 2 == 0:
        a[i] = 1
b = [1 for _ in range(n)]
for i in range(n):
    if i % 2 == 0:
        b[i] = 0

res0 = 0
for x, y in zip(cs, a):
    res0 += abs(x - y)
res1 = 0
for x, y in zip(cs, b):
    res1 += abs(x - y)
print(min(res0, res1))

Solution (Python):
s = input()

import numpy as np

s = np.array(list(s))
ans1 = []
ans2 = []
for i in range(len(s)):
    if i%2:
        ans1.append("0")
        ans2.append("1")
    else:
        ans1.append("1")
        ans2.append("0")

print(min(sum(s==ans1), sum(s==ans2)))

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

Solution (Python):
s=input()

cnt_start0 = 0
cnt_start1 = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == '0':
            cnt_start1 += 1
        if s[i] == '1':
            cnt_start0 += 1
    if i % 2 == 1:
        if s[i] == '0':
            cnt_start0 += 1
        if s[i] == '1':
            cnt_start1 += 1

print(min(cnt_start0, cnt_start1))