AtCoder Beginner Contest 124 - Coloring Colorfully

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-----
000

-----Sample Output-----
1

The condition can be satisfied by repainting the middle tile white.

Difficulty: EASY

Starter code:

Solutions:
s = input()
mae = ''
cnt = 0
for i in range(len(s)):
	if mae == s[i]:
		cnt += 1
		if s[i] == '0':
			mae = '1'
		else:
			mae = '0'
	else:
		mae = s[i]
print(cnt)


ans = 0
S = input()
for (i, j) in enumerate(S):
	j = int(j)
	if i % 2 == j:
		ans += 1
print(min(ans, len(S) - ans))


s = input()
(t, u) = ('', '')
for i in range(len(s)):
	t += '1' if i % 2 == 0 else '0'
	u += '0' if i % 2 == 0 else '1'
s = int(s, 2)
t = int(t, 2)
u = int(u, 2)
print(min(bin(s ^ t).count('1'), bin(s ^ u).count('1')))


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


s = input()
n = len(s)
w = 0
for i in range(n):
	w += (s[i] == '0') * (i % 2) + (s[i] == '1') * ((i + 1) % 2)
print(min(w, n - w))


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


S = input()
ans = 0
a = S[0]
for i in range(1, len(S)):
	if a == S[i]:
		ans += 1
	if a == '0':
		a = '1'
	else:
		a = '0'
print(ans)


S = input()
a = ['0', '1']
count = 0
n = len(S)
for i in range(n):
	if S[i] == a[i % 2]:
		count += 1
print(min(count, n - count))


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


from collections import Counter
moji = str(input())
guall = len(moji) // 2
kiall = guall + len(moji) % 2
gucount = dict(Counter(moji[1::2]))
kicount = dict(Counter(moji[0::2]))
if len(moji) == 1:
	ans = 0
elif max(gucount, key=gucount.get) != max(kicount, key=kicount.get):
	ans = guall - max(gucount.values()) + kiall - max(kicount.values())
elif kiall - max(kicount.values()) > guall - max(gucount.values()):
	ans = max(kicount.values()) + guall - max(gucount.values())
else:
	ans = max(gucount.values()) + kiall - max(kicount.values())
print(ans)


s = input()
e = s[::2]
o = s[1::2]
print(min(e.count('1') + o.count('0'), e.count('0') + o.count('1')))


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


(*s,) = map(int, input())
a = 0
for i in range(1, len(s)):
	a += s[i] == s[i - 1]
	s[i] = 1 - s[i - 1]
print(a)


a = list(input())
b = list(reversed(a))
ans_f = 0
ans_r = 0
for i in range(len(a) - 1):
	if a[i] == a[i + 1]:
		a[i + 1] = str(abs(int(a[i]) - 1))
		ans_f += 1
for i in range(len(a) - 1):
	if b[i] == b[i + 1]:
		b[i + 1] = str(abs(int(b[i]) - 1))
		ans_r += 1
print(min(ans_f, ans_r))


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


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


s = input()
x = ''
y = ''
x_con = 0
y_con = 0
for i in range(len(s)):
	if i % 2 == 0:
		x += '0'
		y += '1'
	else:
		x += '1'
		y += '0'
for i in range(len(s)):
	if s[i] != x[i]:
		x_con += 1
	if s[i] != y[i]:
		y_con += 1
print(min(x_con, y_con))


s = input()
if len(s) == 1:
	ans = 0
else:
	ans_w = sum([1 for i in s[::2] if i != '1']) + sum([1 for i in s[1::2] if i != '0'])
	ans_b = sum([1 for i in s[::2] if i != '0']) + sum([1 for i in s[1::2] if i != '1'])
	ans = min([ans_w, ans_b])
print(ans)


a = 0
for (i, s) in enumerate(input()):
	a += i % 2 ^ int(s)
print(min(a, i - a + 1))


S = input()
N = len(S)
(s1, s2) = ('', '')
for i in range(N):
	if i % 2 == 0:
		s1 += '1'
		s2 += '0'
	else:
		s1 += '0'
		s2 += '1'
(a1, a2) = (0, 0)
for i in range(N):
	if s1[i] != S[i]:
		a1 += 1
	if s2[i] != S[i]:
		a2 += 1
ans = min(a1, a2)
print(ans)


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


S = input()
(idx1, idx2) = (0, 1)
(cnt1, cnt2) = (0, 0)
for s in S:
	s = int(s)
	if s != idx1:
		cnt1 += 1
	if s != idx2:
		cnt2 += 1
	(idx1, idx2) = (abs(idx1 - 1), abs(idx2 - 1))
print(min(cnt1, cnt2))


s = input()
a = s[::2].count('0') + s[1::2].count('1')
b = s[::2].count('1') + s[1::2].count('0')
print(min(a, b))


s = input()
if s[0] == '1':
	ans = 0
	for i in range(len(s)):
		if i % 2 == 0 and s[i] != '1':
			ans += 1
		elif i % 2 == 1 and s[i] != '0':
			ans += 1
else:
	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
print(ans)


s = input()
z = sum([int(s[i]) == i % 2 for i in range(len(s))])
print(min(z, len(s) - z))


s = input()
ans = [0, 0]
for i in range(len(s)):
	now = int(s[i])
	ans[0] += now ^ 0 ^ i % 2
	ans[1] += now ^ 1 ^ i % 2
print(min(ans))


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


s = list(input())
a = s[::2].count('0') + s[1::2].count('1')
b = s[::2].count('1') + s[1::2].count('0')
print(len(s) - max(a, b))


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


s = input()
n = len(s)
li = [0] * n
for i in range(n):
	if s[i] == '1':
		li[i] = 1
b = [0] * n
w = [1] * n
for i in range(n):
	if i % 2 == 1:
		b[i] = 1
		w[i] = 0
cnt_1 = 0
cnt_2 = 0
for i in range(n):
	cnt_1 += li[i] ^ b[i]
	cnt_2 += li[i] ^ w[i]
ans = min(cnt_1, cnt_2)
print(ans)


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


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


S = input()
N = len(S)
(a1, a2) = (0, 0)
for i in range(N):
	if i % 2 == 0 and S[i] == '1':
		a1 += 1
	if i % 2 == 1 and S[i] == '0':
		a1 += 1
for i in range(N):
	if i % 2 == 0 and S[i] == '0':
		a2 += 1
	if i % 2 == 1 and S[i] == '1':
		a2 += 1
print(min(a1, a2))


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


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


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


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


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


s = input()
a = int(('10' * 10 ** 5)[:len(s)], 2)
s = int(s, 2)
c = lambda x: str(bin(x ^ s)).count('1')
print(min(c(a), c(a >> 1)))


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


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


S = input()
b = 1
B = 0
for i in S:
	if int(i) != int(b):
		B += 1
	b = not b
l = len(S)
print(min(B, l - B))


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


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


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


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


c = 0
for (i, n) in enumerate(input()):
	c += i % 2 ^ int(n)
print(min(c, i - c + 1))


s = input()
a = '01'
b = x = y = 0
for i in s:
	if i == a[b]:
		x += 1
	if i == a[~b]:
		y += 1
	b = ~b
print(len(s) - max(x, y))


s = [int(i) for i in input()]
a = s[1::2]
b = s[::2]
print(min(a.count(0) + sum(b), sum(a) + b.count(0)))


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)


s = input()
tmp1 = ''
tmp2 = ''
for i in range(len(s)):
	if i % 2 == 0:
		tmp1 += '0'
		tmp2 += '1'
	else:
		tmp1 += '1'
		tmp2 += '0'
diff_tmp1 = 0
diff_tmp2 = 0
for i in range(len(s)):
	if tmp1[i] != s[i]:
		diff_tmp1 += 1
	elif tmp2[i] != s[i]:
		diff_tmp2 += 1
print(min(diff_tmp1, diff_tmp2))


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


s = input()
c = 0
nums = ['0', '1']
for (i, v) in enumerate(s):
	if v == nums[i % 2]:
		c += 1
print(min(c, len(s) - c))


s = list(input())
for i in range(0, len(s), 2):
	s[i] = str(int(s[i]) + 1 & 1)
print(min(s.count('0'), s.count('1')))


S = input()
a1 = 0
a2 = 0
p1 = '1'
p2 = '0'
for s in S:
	if s != p1:
		a1 += 1
	else:
		a2 += 1
	p = p1
	p1 = p2
	p2 = p
print(min(a1, a2))


S = input()
temp = 0
for i in range(len(S)):
	if S[i] != '0' and i % 2 == 0:
		temp += 1
	if S[i] != '1' and i % 2 == 1:
		temp += 1
ans = temp
temp = 0
for i in range(len(S)):
	if S[i] != '0' and i % 2 == 1:
		temp += 1
	if S[i] != '1' and i % 2 == 0:
		temp += 1
if temp < ans:
	ans = temp
print(ans)


s = input()
Z = 0
W = 0
for i in range(len(s)):
	if int(s[i]) == i % 2:
		Z += 1
	else:
		W += 1
print(min(Z, W))


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


import copy
S_0 = list(input())
S = [int(n) for n in S_0]
S_1 = copy.copy(S)
S_1[0] = 1 - S_1[0]
l = len(S)
i = 0
cnt_0 = 0
cnt_1 = 1
for i in range(l - 1):
	if S[i + 1] == S[i]:
		cnt_0 += 1
		S[i + 1] = 1 - S[i]
for i in range(l - 1):
	if S_1[i + 1] == S_1[i]:
		cnt_1 += 1
		S_1[i + 1] = 1 - S_1[i]
print(min([cnt_0, cnt_1]))


s = input()
ev = s[0::2]
od = s[1::2]
print(min(ev.count('1') + od.count('0'), ev.count('0') + od.count('1')))


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


s = input()
c1 = s[::2].count('0') + s[1::2].count('1')
c2 = s[::2].count('1') + s[1::2].count('0')
print(min(c1, c2))


s = input()
odd_0 = 0
odd_1 = 0
even_0 = 0
even_1 = 0
for i in range(len(s)):
	if i % 2 == 0:
		if s[i] == '0':
			odd_0 += 1
		else:
			odd_1 += 1
	elif s[i] == '0':
		even_0 += 1
	else:
		even_1 += 1
a = odd_0 + even_1
b = odd_1 + even_0
ans = min(a, b)
print(ans)


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


s = input()
cnt1 = 0
cnt2 = 0
for (i, c) in enumerate(s):
	cnt1 += int(c) != i % 2
	cnt2 += int(c) != (i + 1) % 2
print(min(cnt1, cnt2))


S = input()
d0 = 0
d1 = 0
for i in range(len(S)):
	d0 += int(S[i]) != i % 2
	d1 += int(S[i]) != (i + 1) % 2
print(min(d0, d1))


s = input()
n = sum(((i + int(c)) % 2 for (i, c) in enumerate(s)))
print(min(n, len(s) - n))


s = list(map(int, list(str(input()))))
a = s[::2]
b = s[1::2]
c = a.count(1) + b.count(0)
d = a.count(0) + b.count(1)
print(min(c, d))


s = input()
n = len(s)
count = 0
for i in range(n):
	if i & 1 ^ int(s[i]):
		count += 1
print(min(count, n - count))


s = input()
b = l = r = 0
for i in s:
	l += int(i) == b
	r += int(i) != b
	b ^= 1
print(min(l, r))


s = input()
cnt = 0
for (i, ss) in enumerate(s):
	if ss == str(i % 2):
		cnt += 1
print(min(cnt, len(s) - cnt))


s = input()
l = '1' + '01' * (len(s) // 2)
ans = 0
for i in range(len(s)):
	if s[i] == l[i]:
		ans += 1
print(min(ans, len(s) - ans))


def resolve():
	S = input()
	ans1 = 0
	res1 = 0
	ans2 = 1
	res2 = 0
	for item in S:
		item = int(item)
		if ans1 % 2 != item:
			res1 += 1
		if ans2 % 2 != item:
			res2 += 1
		ans1 += 1
		ans2 += 1
	print(min(res2, res1))

def __starting_point():
	resolve()
__starting_point()


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


S = input()

def s(a):
	return sum([(i ^ a ^ int(S[i])) & 1 for i in range(len(S))])
print(min(s(0), s(1)))


S = input()
A = S[0::2].count('1') + S[1::2].count('0')
B = S[0::2].count('0') + S[1::2].count('1')
print(min(A, B))


s = list(input())
ans = 100000.0
for i0 in range(2):
	sum = 0
	for i in range(len(s)):
		x = i + i0
		if str(x % 2) == s[i]:
			sum += 1
	ans = min(sum, ans)
print(ans)


tile = list(map(int, input()))
n = len(tile)
sum = 0
for i in range(n):
	sum += (i - tile[i]) % 2
print(min(sum, n - sum))


def change(W):
	if S[W] == 0:
		S[W] = 1
	else:
		S[W] = 0
S = list(map(int, input()))
R = len(S)
B = R
Z = list(S)
for K in range(2):
	A = 0
	if S[0] == K:
		A += 1
		change(0)
	for L in range(R - 1):
		if S[L] == S[L + 1]:
			A += 1
			change(L + 1)
	if B >= A:
		B = A
	S = Z
print(B)


S = list(map(int, list(input())))
first_letter = S[0]
second_letter = 0 if first_letter else 1
res = 0
res += len([i for i in S[0::2] if i != first_letter])
res += len([i for i in S[1::2] if i != second_letter])
print(res)


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


import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007

def main():
	S = readline().strip()
	count = 0
	for (i, c) in enumerate(S):
		if i % 2 == int(c):
			count += 1
	print(min(count, len(S) - count))
	return

def __starting_point():
	main()
__starting_point()


import sys
input = sys.stdin.readline
import numpy as np

def main():
	S = np.array(list(map(int, input().rstrip())))
	L = len(S)
	A = np.arange(L) & 1
	B = 1 - A
	x1 = (A != S).sum()
	x2 = (B != S).sum()
	print(min(x1, x2))

def __starting_point():
	main()
__starting_point()


s = list(str(input()))
cnt = 0
if len(s) > 1 and s[0] == s[1]:
	if s[0] == '1':
		s[1] = '0'
	else:
		s[1] = '1'
	cnt += 1
for i in range(1, len(s) - 1):
	if s[i] == s[i + 1]:
		s[i + 1] = s[i - 1]
		cnt += 1
print(cnt)


n = list(input())
cnt1 = 0
cnt2 = 0
for i in range(len(n)):
	if i % 2 == 0:
		if n[i] == '0':
			cnt1 += 1
		else:
			cnt2 += 1
	elif n[i] == '1':
		cnt1 += 1
	else:
		cnt2 += 1
print(min(cnt1, cnt2))


s = input()
words = [w for w in s]
cnt = 0
for r in range(len(words) - 1):
	if words[r + 1] == words[r]:
		if words[r + 1] == '0':
			words[r + 1] = '1'
		else:
			words[r + 1] = '0'
		cnt += 1
print(cnt)


s = input()
os = s[1::2]
es = s[::2]
l = os.count('0') + es.count('1')
print(min(l, len(s) - l))


s = input()
p = int(''.join(map(str, [i % 2 for i in range(1, len(s) + 1)])), 2)
print(min((bin(int(s, 2) ^ n).count('1') for n in [p, p >> 1])))


n = input()
sum = 0
for i in range(len(n)):
	if int(n[i]) == i % 2:
		sum += 1
print(min(sum, len(n) - sum))


t = list(input())
ans = min(t[::2].count('0') + t[1::2].count('1'), t[::2].count('1') + t[1::2].count('0'))
print(ans)


S = list(map(int, list(input())))
ans = 0
for i in range(len(S)):
	if S[i] != i % 2:
		ans += 1
print(min(ans, len(S) - ans))


s = str(input())
con = 0
con2 = 0
ans = 0
ans2 = 0
for i in range(len(s)):
	if i % 2 == 0:
		ans += 1
		if s[i] == '0':
			con += 1
	else:
		ans2 += 1
		if s[i] == '1':
			con2 += 1
L = [con + con2, ans - con + (ans2 - con2)]
print(min(L))


s = input()
a = 0
b = 0
for (index, i) in enumerate(s):
	if int(i) == index % 2:
		a += 1
	else:
		b += 1
print(min(a, b))


S = input()
cnt = 0
for (i, s) in enumerate(S):
	cnt += int(s) == i % 2
print(min(cnt, len(S) - cnt))


s = input()
c = 0
for i in range(len(s)):
	if int(s[i]) != i % 2:
		c += 1
print(min(c, len(s) - c))


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


S = input()
N = len(S)
(O, E) = (0, 0)
for (i, s) in enumerate(S):
	O += i % 2 ^ int(s)
	E += i % 2 ^ (not int(s))
print(min(O, E))


S = input()
count = sum((int(s) != i % 2 for (i, s) in enumerate(S)))
print(min(count, len(S) - count))


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


import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
input = sys.stdin.readline

def RD():
	return input().rstrip()

def F():
	return float(input().rstrip())

def I():
	return int(input().rstrip())

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

def MF():
	return map(float, input().split())

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

def TI():
	return tuple(map(int, input().split()))

def LF():
	return list(map(float, input().split()))

def Init(H, W, num):
	return [[num for i in range(W)] for j in range(H)]

def main():
	S = input().rstrip()
	l = len(S)
	a1 = 0
	a0 = 0
	for i in range(l):
		if i % 2 == 0:
			if S[i] == '1':
				a1 += 1
			else:
				a0 += 1
		elif S[i] == '0':
			a1 += 1
		else:
			a0 += 1
	print(min(a0, a1))

def __starting_point():
	main()
__starting_point()


S = input()
norm = 0
for (i, s) in enumerate(S):
	if i % 2 == int(s):
		norm += 1
print(min(norm, len(S) - norm))


s = input()
n = len(s)
a = ''
for x in range(n):
	if x % 2 == 0:
		a = a + '1'
	else:
		a = a + '0'
count = 0
for y in range(n):
	if s[y] != a[y]:
		count += 1
print(min(count, n - count))


import sys
import copy
import math
import itertools
import numpy as np
S = input()
cnt = [0, 0]
for i in range(len(S)):
	if i % 2 == 0 and int(S[i]) == 1:
		cnt[0] += 1
	elif i % 2 == 1 and int(S[i]) == 0:
		cnt[0] += 1
	if i % 2 == 0 and int(S[i]) == 0:
		cnt[1] += 1
	elif i % 2 == 1 and int(S[i]) == 1:
		cnt[1] += 1
if cnt[0] <= cnt[1]:
	print(cnt[0])
else:
	print(cnt[1])


s = input()
c = 0
for x in range(len(s)):
	c += 1 if s[x] != str(x % 2) else 0
print(c if c < x + 1 - c else x + 1 - c)


s = input()
changes = len([i for (i, tile) in enumerate(s) if i % 2 != int(tile)])
print(min(changes, len(s) - changes))


s = input()
o1 = s[::2].count('1')
o0 = len(s[::2]) - o1
e1 = s[1::2].count('1')
e0 = len(s[1::2]) - e1
print(min(o1 + e0, o0 + e1))


S = input()
S0 = S[::2]
S1 = S[1::2]
print(min(len(S) - S0.count('0') - S1.count('1'), len(S) - S0.count('1') - S1.count('0')))


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


S = input()
N = len(S)
ans = 0
if S[0] == '0':
	for i in range(1, N):
		if i % 2 == 0 and S[i] == '1':
			ans += 1
		if i % 2 == 1 and S[i] == '0':
			ans += 1
else:
	for i in range(1, N):
		if i % 2 == 0 and S[i] == '0':
			ans += 1
		if i % 2 == 1 and S[i] == '1':
			ans += 1
print(ans)


s = input()
s_length = len(s)
keep = '01' * 100000
keep_1 = keep[:s_length]
keep_2 = keep[1:s_length + 1]
ans_1 = 0
ans_2 = 0
for i in range(s_length):
	if s[i] != keep_1[i]:
		ans_1 += 1
	else:
		ans_2 += 1
print(min(ans_1, ans_2))


s = input()
S = len(s)
li_0 = []
for i in s:
	li_0.append(int(i))
li = [0, 1] * 10 ** 5
li_1 = []
li_2 = []
cnt1 = 0
cnt2 = 0
for i in range(S):
	li_1.append(li[i])
	li_2.append(li[i + 1])
for i in range(S):
	if li_0[i] == li_1[i]:
		cnt1 += 1
	if li_0[i] == li_2[i]:
		cnt2 += 1
if cnt1 >= cnt2:
	print(S - cnt1)
else:
	print(S - cnt2)


s = input()
a = '10' * 10 ** 5
b = '01' * 10 ** 5
(aa, bb) = (0, 0)
for i in range(len(s)):
	if s[i] == a[i]:
		bb += 1
	else:
		aa += 1
print(min(aa, bb))


S = str(input())
N = len(S)
cnt = 0
for i in range(N):
	if S[0] == '0':
		if i % 2 == 0 and S[i] != '0':
			cnt += 1
		elif i % 2 == 1 and S[i] == '0':
			cnt += 1
	elif i % 2 == 0 and S[i] != '1':
		cnt += 1
	elif i % 2 == 1 and S[i] == '1':
		cnt += 1
print(cnt)


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


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


S = list(input())
cnt1 = 0
for (i, s) in enumerate(S):
	if i % 2 == 0:
		if s != '0':
			cnt1 += 1
	elif s != '1':
		cnt1 += 1
cnt2 = 0
for (i, s) in enumerate(S):
	if i % 2 == 0:
		if s != '1':
			cnt2 += 1
	elif s != '0':
		cnt2 += 1
print(min(cnt1, cnt2))


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


S = list(input())
n = len(S)
lens = n // 2
plus = False
if n % 2 != 0:
	plus = True
test1 = '01' * lens
test2 = '10' * lens
if plus:
	test1 += '0'
	test2 += '1'
(test1, test2) = (list(test1), list(test2))
(count1, count2) = (0, 0)
for i in range(n):
	if S[i] != test1[i]:
		count1 += 1
	if S[i] != test2[i]:
		count2 += 1
print(min(count1, count2))


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


s = input()
n = len(s)
a = sum((i % 2 ^ int(s[i]) for i in range(n)))
print(min(a, n - a))


s = input()
a = [0] * len(s)
print(len(a) - s[1::2].count('0') - s[::2].count('1') if s[0] == '1' else len(a) - s[1::2].count('1') - s[::2].count('0'))


S = list(map(int, input()))
N = len(S)
print(min([sum([(i % 2 - S[i] + m) % 2 for i in range(N)]) for m in range(2)]))


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


s = list(map(int, input()))
o = s[0::2]
e = s[1::2]
a = o.count(0) + e.count(1)
b = o.count(1) + e.count(0)
print(min(a, b))


s = input()
s1 = []
s2 = []
ans1 = 0
ans2 = 0
for i in range(len(s)):
	if i % 2 != 0:
		s1.append('0')
	else:
		s1.append('1')
for i in range(len(s)):
	if i % 2 == 0:
		s2.append('0')
	else:
		s2.append('1')
for (x, y) in zip(s, s1):
	if x != y:
		ans1 += 1
for (x, y) in zip(s, s2):
	if x != y:
		ans2 += 1
print(min(ans1, ans2))


S = input()
odd = S[1::2]
even = S[::2]
print(min(odd.count('1') + even.count('0'), even.count('1') + odd.count('0')))


s = input()
start = ['0', '1']
ans = 10 ** 6
for offset in [0, 1]:
	now = 0
	for i in range(len(s)):
		j = (i + offset) % 2
		if s[i] != start[j]:
			now += 1
	ans = min(ans, now)
print(ans)


s = input()
l = len(s)
(a, b) = ('', '')
for i in range(l):
	if i % 2 == 0:
		a += '1'
		b += '0'
	else:
		a += '0'
		b += '1'
(diff_a, diff_b) = (0, 0)
for i in range(l):
	if a[i] != s[i]:
		diff_a += 1
	if b[i] != s[i]:
		diff_b += 1
print(min(diff_a, diff_b))


s = [*input()]
n = len(s)
t = ['1' if i % 2 == 0 else '0' for i in range(n)]
r = [i == j for (i, j) in zip(s, t)]
print(min(sum(r), n - sum(r)))


S = [int(c) for c in input()]
T = [i % 2 for i in range(len(S))]
q = 0
for (s, t) in zip(S, T):
	q += s != t
print(min(q, len(S) - q))


s = list(map(int, input()))
cnt = 0
for i in range(0, len(s) - 1):
	if s[i] == s[i + 1]:
		s[i + 1] = abs(s[i + 1] * 1 - 1)
		cnt += 1
print(cnt)


N = list(map(int, list(input())))
p1 = 0
p2 = 0
flag = 0
for i in N:
	if i == flag:
		p1 += 1
	else:
		p2 += 1
	flag = 1 - flag
print(min(p1, p2))


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


s = input()
ret = [0, 0]
for i in range(len(s)):
	ret[(int(s[i]) + i) % 2] += 1
print(min(ret))


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


S = list(input())
l = len(S)
s = 0
for i in range(l - 1):
	if S[i] == S[i + 1] and S[i] == '0':
		s += 1
		S[i + 1] = '1'
	elif S[i] == S[i + 1] and S[i] == '1':
		s += 1
		S[i + 1] = '0'
print(s)


s = input()
start_0 = 0
start_1 = 0
for (i, j) in enumerate(s):
	if i % 2 == 0 and j == '1':
		start_0 += 1
	elif i % 2 != 0 and j == '0':
		start_0 += 1
	elif i % 2 == 0 and j == '0':
		start_1 += 1
	elif i % 2 != 0 and j == '1':
		start_1 += 1
print(min(start_0, start_1))


s = list(input())
a = s[::2]
b = s[1::2]
x = a.count('0')
y = b.count('0')
print(min(x + len(b) - y, len(a) - x + y))


s = input()
n = len(s)
l = [0 for _ in range(n)]
for i in range(n):
	if s[i] == '1':
		l[i] = 1
brack = [0 if i % 2 == 1 else 1 for i in range(n)]
white = [1 if i % 2 == 1 else 0 for i in range(n)]
(cnt_1, cnt_2) = (0, 0)
for i in range(n):
	cnt_1 += l[i] ^ brack[i]
	cnt_2 += l[i] ^ white[i]
print(min(cnt_1, cnt_2))


S = input()
c = S[::2].count('0') + S[1::2].count('1')
d = S[::2].count('1') + S[1::2].count('0')
print(min(c, d))


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


import sys
s = sys.stdin.buffer.readline().rstrip()
n = len(s)
a = 0
for i in range(n):
	a += s[i] % 2 == i % 2
print(min(a, n - a))


S = input()
c = 0
x = 0
for i in S:
	if i == str(c):
		x += 1
	c = (c + 1) % 2
print(min(x, len(S) - x))


S = input()
N = len(S)
c1 = S[1::2].count('0')
c2 = S[0::2].count('1')
sum1 = N - c1 - c2
sum2 = c1 + c2
print(min(sum1, sum2))


S = input()
ans = 0
if S[0] == '0':
	ans += S[0::2].count('1')
	ans += S[1::2].count('0')
else:
	ans += S[0::2].count('0')
	ans += S[1::2].count('1')
print(ans)


S = input()
n = len(S)
ans1 = ('01' * 10 ** 6)[:n]
ans2 = ('10' * 10 ** 6)[:n]
count = 0
for (i, j) in zip(S, ans1):
	if i != j:
		count += 1
print(min(count, n - count))


result1 = 0
S = input()
l = len(S)
for i in range(l):
	if i % 2 == 0:
		if S[i] == '0':
			result1 += 1
	elif S[i] == '1':
		result1 += 1
print(min(result1, l - result1))


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


S = list(input())
f = S[0]
c = 0
for i in range(1, len(S)):
	if i % 2 == 1:
		if f == S[i]:
			c += 1
	elif f != S[i]:
		c += 1
print(c)


(*s,) = map(int, input())
n = len(s)
a = sum(s[::2]) + n // 2 - sum(s[1::2])
print(min(a, n - a))


S = input()
s = []
total = 0
for i in range(len(S)):
	s.append(int(S[i]))
for i in range(0, len(s) - 1):
	if s[i] == s[i + 1]:
		total += 1
		s[i + 1] = abs(1 - s[i])
print(total)


S = input()
N = len(S)
A = len([i for i in range(N) if str(i % 2) == S[i]])
print(min(A, N - A))


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


S = input()
A = [1 if i % 2 == 0 else 0 for i in range(len(S))]
B = [1 if i % 2 != 0 else 0 for i in range(len(S))]
A_cost = 0
B_cost = 0
i = 0
for i in range(len(S)):
	if int(S[i]) != A[i]:
		A_cost += 1
	if int(S[i]) != B[i]:
		B_cost += 1
print(min(A_cost, B_cost))


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


s = input()
print(len(s) - max(s[0::2].count('0') + s[1::2].count('1'), s[0::2].count('1') + s[1::2].count('0')))


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


s = input()
n = len(s)
temp = len([i for i in range(n) if int(s[i]) == i % 2])
print(min(temp, n - temp))


s = input()
n1 = s[::2].count('0') + s[1::2].count('1')
n2 = s[::2].count('1') + s[1::2].count('0')
print(min(n1, n2))


(*S,) = map(int, input())
(f, g) = (S[::2], S[1::2])
u = sum(f) - sum(g)
print(min(len(g) + u, len(f) - u))


s = list(input())
r1 = 0
r2 = 0
for (ii, ss) in enumerate(s):
	if ii % 2 == 0:
		if ss == '0':
			r1 += 1
		else:
			r2 += 1
	elif ss == '1':
		r1 += 1
	else:
		r2 += 1
print(min(r1, r2))


S = [int(i) for i in input()]
print(min(S[0::2].count(0) + S[1::2].count(1), S[0::2].count(1) + S[1::2].count(0)))


S = input()
SE = S[::2]
SO = S[1::2]
print(min(SE.count('1') + SO.count('0'), SE.count('0') + SO.count('1')))


n = input()
n1 = n[::2]
n2 = n[1::2]
nc = n1.count('0') + n2.count('1')
print(min(nc, len(n) - nc))


s = input()
n = len(s)
(x, y) = (0, 0)
for i in range(n):
	if i % 2 == 0:
		if s[i] == '0':
			y += 1
		else:
			x += 1
	elif s[i] == '0':
		x += 1
	else:
		y += 1
print(min(x, y))


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


s = input()
s = list(s)
c = 0
for i in range(0, len(s), 2):
	if s[i] == '0':
		c += 1
for i in range(1, len(s), 2):
	if s[i] == '1':
		c += 1
d = 0
for i in range(0, len(s), 2):
	if s[i] == '1':
		d += 1
for i in range(1, len(s), 2):
	if s[i] == '0':
		d += 1
print(min(c, d))


S = [int(x) for x in list(input())]
bw = [0, 1]
wb = [1, 0]
ans1 = 0
ans2 = 0
for i in range(len(S)):
	if S[i] != bw[i % 2]:
		ans1 += 1
	if S[i] != wb[i % 2]:
		ans2 += 1
print(min(ans1, ans2))


s = [int(x) for x in list(input())]
x = len(s)
y = [0 if i % 2 == 0 else 1 for i in range(x)]
z = [1 if i % 2 == 0 else 0 for i in range(x)]
count1 = 0
count2 = 0
ans1 = list(zip(s, y))
ans2 = list(zip(s, z))
for a in ans1:
	if a[0] != a[1]:
		count1 += 1
for a in ans2:
	if a[0] != a[1]:
		count2 += 1
print(min(count1, count2))


s = input()
l = len(s)
t = 0
for i in range(l):
	t = t + (int(s[i]) * 2 - 1) * (-1) ** i
if t < 0:
	t = -t
print(int((l - t) / 2))


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


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


s = input()
print(s[0::2].count(str(1 - int(s[0]))) + s[1::2].count(s[0]))


S = input()
n = len(S)
print(min(sum((x != y for (x, y) in zip(S, ('01' * (n // 2 + 1))[:n]))), sum((x != y for (x, y) in zip(S, ('10' * (n // 2 + 1))[:n])))))


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


s = input()
print(min(sum([s[0::2].count('1'), s[1::2].count('0')]), sum([s[0::2].count('0'), s[1::2].count('1')])))


S = list(input())
ctr = S[::2].count('0') + S[1::2].count('1')
answer = min(ctr, len(S) - ctr)
print(answer)


import os
import sys

def main():
	S = input()
	ans_1 = 0
	ans_2 = 0
	for (i, s) in enumerate(S):
		if i % 2 == 0 and s == '1':
			ans_1 += 1
		elif i % 2 == 1 and s == '0':
			ans_1 += 1
		if i % 2 == 0 and s == '0':
			ans_2 += 1
		elif i % 2 == 1 and s == '1':
			ans_2 += 1
	print(min(ans_1, ans_2))

def __starting_point():
	main()
__starting_point()


c = list(input())
a = c[::2]
b = c[1::2]
print(min(a.count('0') + b.count('1'), a.count('1') + b.count('0')))


s = input()
l1 = s[::2]
l2 = s[1::2]
c1 = l1.count('0') + l2.count('1')
c2 = l1.count('1') + l2.count('0')
print(min(c1, c2))


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


S = input()
b = 1
B = 0
for i in S:
	if i != str(b):
		B += 1
	b = 1 - b
l = len(S)
print(min(B, l - B))


n = input()
print(min(n[0::2].count('0') + n[1::2].count('1'), n[0::2].count('1') + n[1::2].count('0')))


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


a = list(input())
s = 0
for i in range(len(a)):
	if i % 2 == int(a[i]):
		s = s + 1
m = min(s, len(a) - s)
print(m)


S = input()
(a, c) = (0, True)
for i in range(len(S)):
	if int(S[i]) != c:
		a += 1
	c = not c
print(min(a, len(S) - a))


S = input()
checker = '01' * 100001
keep1 = checker[:len(S)]
keep2 = checker[1:len(S) + 1]
ans_1 = 0
ans_2 = 0
for i in range(len(S)):
	if S[i] != keep1[i]:
		ans_1 += 1
	else:
		ans_2 += 1
print(min(ans_1, ans_2))


s = input()
n = len(s)
s0 = '01' * (n // 2)
s1 = '10' * (n // 2)
if n % 2 == 1:
	s0 += '0'
	s1 += '1'
a0 = 0
a1 = 0
for i in range(n):
	if s[i] != s0[i]:
		a0 += 1
	if s[i] != s1[i]:
		a1 += 1
print(min(a0, a1))


import copy
S = input()
ListS = list(S)
revListS = copy.deepcopy(ListS)
norm = 0
rev = 0
N = len(ListS)
for i in range(1, N):
	if ListS[i] == ListS[i - 1]:
		ListS[i] = str(abs(int(ListS[i]) - 1))
		norm += 1
	if revListS[N - i - 1] == revListS[N - i]:
		revListS[N - i - 1] = str(abs(int(revListS[N - i - 1]) - 1))
		rev += 1
res = min(norm, rev)
print(res)


h = str(input())
r = 0
for (i, x) in enumerate(h):
	if i % 2 != int(x):
		r += 1
print(min(r, len(h) - r))


S = input()
res1 = S[::2].count('0') + S[1::2].count('1')
res2 = S[1::2].count('0') + S[::2].count('1')
print(min(res1, res2))


s = input()
ptn1 = s[::2].count('0') + s[1::2].count('1')
ptn2 = s[::2].count('1') + s[1::2].count('0')
print(min(ptn1, ptn2))


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


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


s = input()
n = len(s)
count = 0
for i in range(n):
	count += int(int(s[i]) != i % 2)
print(min(count, n - count))


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


S = input()
left = S[0]
ans = 0
for i in range(1, len(S)):
	if left == '1' and S[i] == '1':
		left = '0'
		ans += 1
		continue
	elif left == '0' and S[i] == '0':
		left = '1'
		ans += 1
		continue
	else:
		left = S[i]
print(ans)


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


s = input()
b = c = 0
for i in s:
	c += int(i) == b
	b ^= 1
print(min(c, len(s) - c))


s = input()
c1 = s[::2].count('1')
c2 = s[1::2].count('0')
total = c1 + c2
print(min(total, len(s) - total))


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


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


S = list(input())
print(len(S) - max(S[1::2].count('0') + S[0::2].count('1'), S[1::2].count('1') + S[0::2].count('0')))


s = input()
i = 0
ans = 0
while i < len(s):
	if int(s[i]) == i % 2:
		ans += 1
	i += 1
print(min(ans, i - ans))


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


S = input()
ans = 0
flag = 0
for i in S:
	if int(i) == flag:
		ans += 1
	flag = abs(flag - 1)
print(min(ans, len(S) - ans))


(str10, str01) = ('', '')
for i in range(5 * 10 ** 4 + 1):
	str10 += '10'
	str01 += '01'
s = str(input())
len_s = len(s)
str10 = str10[:len_s]
str01 = str01[:len_s]
(cnt10, cnt01) = (0, 0)
for i in range(len_s):
	if s[i] != str10[i]:
		cnt10 += 1
	if s[i] != str01[i]:
		cnt01 += 1
print(min(cnt10, cnt01))


S = input()
ans1 = S[::2].count('1') + S[1::2].count('0')
ans2 = S[::2].count('0') + S[1::2].count('1')
print(min(ans1, ans2))


S = input()
c = S[::2].count('1')
c += S[1::2].count('0')
if c > len(S) / 2:
	c = len(S) - c
print(c)


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


import copy
S = list(input())
S_ = copy.deepcopy(S)
N = len(S)
ans = N
cnt = 0
for i in range(N - 1):
	if S[i] == S[i + 1]:
		cnt += 1
		if S[i + 1] == '0':
			S[i + 1] = '1'
		else:
			S[i + 1] = '0'
print(min(cnt, ans))


a = input()
b = int(len(a))
c = 0
d = 0
if b % 2 == 0:
	for i in range(b // 2):
		if a[2 * i] == '1':
			c = c + 1
		if a[2 * i + 1] == '0':
			c = c + 1
	for i in range(b // 2):
		if a[2 * i] == '0':
			d = d + 1
		if a[2 * i + 1] == '1':
			d = d + 1
	if c > d:
		print(d)
	else:
		print(c)
if b % 2 == 1:
	for i in range(b // 2):
		if a[2 * i] == '1':
			c = c + 1
		if a[2 * i + 1] == '0':
			c = c + 1
	if a[-1] == '1':
		c = c + 1
	for i in range(b // 2):
		if a[2 * i] == '0':
			d = d + 1
		if a[2 * i + 1] == '1':
			d = d + 1
	if a[-1] == '0':
		d = d + 1
	if c > d:
		print(d)
	else:
		print(c)


S = input()
L = len(S)
c = 0
j = 0
for i in range(L):
	c += abs(j - int(S[i]))
	j ^= 1
print(min(c, L - c))


Sarr = tuple(map(int, list(input())))
x = 0
c = 0
for i in Sarr:
	c += x ^ i
	x = x ^ 1
print(min(len(Sarr) - c, c))


S = input()
N = len(S)
cnt_1 = 0
cnt_2 = 0
for i in range(N):
	if i % 2 == 0:
		if S[i] == '0':
			cnt_1 += 1
	elif S[i] == '1':
		cnt_1 += 1
for j in range(N):
	if j % 2 == 0:
		if S[j] == '1':
			cnt_2 += 1
	elif S[j] == '0':
		cnt_2 += 1
print(min(cnt_1, cnt_2))


import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7

def resolve():
	S = input().rstrip()
	n = len(S)
	res1 = res2 = 0
	for i in range(n):
		if i % 2 == 0:
			if S[i] == '0':
				res1 += 1
			else:
				res2 += 1
		elif S[i] == '1':
			res1 += 1
		else:
			res2 += 1
	print(min(res1, res2))

def __starting_point():
	resolve()
__starting_point()


S = list(input())
cnt = 0
for i in range(len(S) - 1):
	if S[i] == S[i + 1] == '0':
		S[i + 1] = '1'
		cnt += 1
	elif S[i] == S[i + 1] == '1':
		S[i + 1] = '0'
		cnt += 1
	else:
		pass
print(cnt)


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


S = input()
c = 0
l = len(S)
for i in range(l):
	if S[i] == str(i % 2):
		c += 1
print(min(c, l - c))


s = input()
result = 10 ** 9
tmp = 0
for (i, c) in enumerate(s):
	if i & 1:
		if c == '0':
			tmp += 1
	elif c == '1':
		tmp += 1
result = min(result, tmp)
tmp = 0
for (i, c) in enumerate(s):
	if i & 1:
		if c == '1':
			tmp += 1
	elif c == '0':
		tmp += 1
result = min(result, tmp)
print(result)


s = [int(x) for x in input()]
s1 = s[::2]
s0 = s[1::2]
print(min(len(s1) - sum(s1) + sum(s0), len(s0) - sum(s0) + sum(s1)))