import sys

input = sys.stdin.readline



S=[]

s=eval(input())

for c in s:

        S.append(c)

S.pop(-1)

print((2*min(S.count("0"), S.count("1"))))
s = eval(input())

n = len(s)



r = 0

b = 0

ans = 0



for i in range(n):

    if s[i] == "0":

        r += 1

    elif s[i] == "1":

        b += 1

    

    if 0 < r and 0 < b:

        r -= 1

        b -= 1

        ans += 2



print(ans)

    
import sys

input = sys.stdin.readline
S = []
s = eval(input())
for c in s:
    S.append(c)
S.pop(-1)
print((2 * min(S.count("0"), S.count("1"))))

s = eval(input())
n = len(s)
r = 0
b = 0
ans = 0
for i in range(n):
    if s[i] == "0":
        r += 1
    elif s[i] == "1":
        b += 1
    if 0 < r and 0 < b:
        r -= 1
        b -= 1
        ans += 2
print(ans)

-import sys - -input = sys.stdin.readline -S = [] -for c in s: -    S.append(c) -S.pop(-1) -print((2 * min(S.count("0"), S.count("1")))) +n = len(s) +r = 0 +b = 0 +ans = 0 +for i in range(n): +    if s[i] == "0": +        r += 1 +    elif s[i] == "1": +        b += 1 +    if 0 < r and 0 < b: +        r -= 1 +        b -= 1 +        ans += 2 +print(ans)