s = eval(input())

a = 0

b = 0

for i in s:

    if i == "1":

        a += 1

    else:

        b += 1

print((len(s)-abs(a-b)))
s = eval(input())

r = 0

b = 0

for i in s:

    if i == "1":r += 1

    else: b += 1



now = max(b,r) - min(b,r)

ans = len(s)-now

print(ans)
s = eval(input())
a = 0
b = 0
for i in s:
    if i == "1":
        a += 1
    else:
        b += 1
print((len(s) - abs(a - b)))

s = eval(input())
r = 0
b = 0
for i in s:
    if i == "1":
        r += 1
    else:
        b += 1
now = max(b, r) - min(b, r)
ans = len(s) - now
print(ans)

-a = 0 +r = 0 -        a += 1 +        r += 1 -print((len(s) - abs(a - b))) +now = max(b, r) - min(b, r) +ans = len(s) - now +print(ans)