from collections import deque

S = eval(input())

dq = deque()

for s in S:

    if not(dq):

        dq.append(s)

        continue

    if int(dq[-1]) + int(s) == 1:

        dq.pop()

    else:

        dq.append(s)

ans = len(S) - len(dq)

print(ans)
S = eval(input())

red = S.count("0")

blue = S.count("1")

ans = len(S) - abs(red-blue)

print(ans)
from collections import deque

S = eval(input())
dq = deque()
for s in S:
    if not (dq):
        dq.append(s)
        continue
    if int(dq[-1]) + int(s) == 1:
        dq.pop()
    else:
        dq.append(s)
ans = len(S) - len(dq)
print(ans)

S = eval(input())
red = S.count("0")
blue = S.count("1")
ans = len(S) - abs(red - blue)
print(ans)

-from collections import deque - -dq = deque() -for s in S: -    if not (dq): -        dq.append(s) -        continue -    if int(dq[-1]) + int(s) == 1: -        dq.pop() -    else: -        dq.append(s) -ans = len(S) - len(dq) +red = S.count("0") +blue = S.count("1") +ans = len(S) - abs(red - blue)