S = list(eval(input()))



last = S.pop(0)

stack = [last]

can_pop = True

cnt = 0

for s in S:

    if last != s and can_pop:

        stack.pop()

        if len(stack) == 0:

            can_pop = False

        # stack.append(s) 読み捨て

        cnt += 2

    else:

        stack.append(s)

        last = s

        can_pop = True



print(cnt)

S = list(eval(input()))



one = 0

zero = 0

for s in S:

    if s == "1":

        one += 1

    else:

        zero += 1

print((min(one, zero) * 2))
S = list(eval(input()))
last = S.pop(0)
stack = [last]
can_pop = True
cnt = 0
for s in S:
    if last != s and can_pop:
        stack.pop()
        if len(stack) == 0:
            can_pop = False
        # stack.append(s) 読み捨て
        cnt += 2
    else:
        stack.append(s)
        last = s
        can_pop = True
print(cnt)

S = list(eval(input()))
one = 0
zero = 0
for s in S:
    if s == "1":
        one += 1
    else:
        zero += 1
print((min(one, zero) * 2))

-last = S.pop(0) -stack = [last] -can_pop = True -cnt = 0 +one = 0 +zero = 0 -    if last != s and can_pop: -        stack.pop() -        if len(stack) == 0: -            can_pop = False -        # stack.append(s) 読み捨て -        cnt += 2 +    if s == "1": +        one += 1 -        stack.append(s) -        last = s -        can_pop = True -print(cnt) +        zero += 1 +print((min(one, zero) * 2))