ans=0

stack=[]

for s in eval(input()):

    if len(stack)>0 and stack[-1]!=s:

        del stack[-1]

        ans+=2

    else:

        stack.append(s)

print(ans)
s=eval(input())

t=s.count("0")

e=s.count("1")

print((len(s)-(max(t,e)-min(t,e))))
ans = 0
stack = []
for s in eval(input()):
    if len(stack) > 0 and stack[-1] != s:
        del stack[-1]
        ans += 2
    else:
        stack.append(s)
print(ans)

s = eval(input())
t = s.count("0")
e = s.count("1")
print((len(s) - (max(t, e) - min(t, e))))

-ans = 0 -stack = [] -for s in eval(input()): -    if len(stack) > 0 and stack[-1] != s: -        del stack[-1] -        ans += 2 -    else: -        stack.append(s) -print(ans) +s = eval(input()) +t = s.count("0") +e = s.count("1") +print((len(s) - (max(t, e) - min(t, e))))