# coding: utf-8



mojiretsu = input().rstrip()



stk = []

ans = 0



for i in mojiretsu:

    if len(stk) > 0 and stk[len(stk)-1] != i:

        stk.pop()

        ans += 2

    else:

        stk.append(i)





print(ans)
# coding: utf-8



s = input().rstrip()



ans = min(s.count("0"), s.count("1")) * 2



print(ans)
# coding: utf-8
mojiretsu = input().rstrip()
stk = []
ans = 0
for i in mojiretsu:
    if len(stk) > 0 and stk[len(stk) - 1] != i:
        stk.pop()
        ans += 2
    else:
        stk.append(i)
print(ans)

# coding: utf-8
s = input().rstrip()
ans = min(s.count("0"), s.count("1")) * 2
print(ans)

-mojiretsu = input().rstrip() -stk = [] -ans = 0 -for i in mojiretsu: -    if len(stk) > 0 and stk[len(stk) - 1] != i: -        stk.pop() -        ans += 2 -    else: -        stk.append(i) +s = input().rstrip() +ans = min(s.count("0"), s.count("1")) * 2