from collections import deque

s=deque(eval(input()))

N=len(s)

A=[]

for i in range(N):

  a=s.popleft()

  if len(A)!=0:

    if A[-1]!=a:

      A.pop()

    else:

      A.append(a)

  else:

    A.append(a)

print((N-len(A)))
from collections import Counter

d={chr(i):0 for i in range(2)}

s=Counter(eval(input()))

d=d.update(s)

print((min(s["0"],s["1"])*2))
from collections import deque

s = deque(eval(input()))
N = len(s)
A = []
for i in range(N):
    a = s.popleft()
    if len(A) != 0:
        if A[-1] != a:
            A.pop()
        else:
            A.append(a)
    else:
        A.append(a)
print((N - len(A)))

from collections import Counter

d = {chr(i): 0 for i in range(2)}
s = Counter(eval(input()))
d = d.update(s)
print((min(s["0"], s["1"]) * 2))

-from collections import deque +from collections import Counter -s = deque(eval(input())) -N = len(s) -A = [] -for i in range(N): -    a = s.popleft() -    if len(A) != 0: -        if A[-1] != a: -            A.pop() -        else: -            A.append(a) -    else: -        A.append(a) -print((N - len(A))) +d = {chr(i): 0 for i in range(2)} +s = Counter(eval(input())) +d = d.update(s) +print((min(s["0"], s["1"]) * 2))