s = input()

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

a = max(count, len(s) - count)

if a % 2 == 0:
    print(len(s))
else:
    print(len(s) - 2)
