S = eval(input())

cnt = 0

prev = 0

while prev != len(S):

    prev = len(S)

    ans = []

    for i, n in enumerate(S):

        if i == 0:

            ans.append(n)

            continue

        if len(ans) > 0 and ans[-1] != n:

            ans.pop()

            cnt += 2

        else:

            ans.append(n)

    S = ''.join(ans)

print(cnt)



N = eval(input())

zero = N.count('0')

one = N.count('1')

ans = min(zero, one) * 2

print(ans)
S = eval(input())
cnt = 0
prev = 0
while prev != len(S):
    prev = len(S)
    ans = []
    for i, n in enumerate(S):
        if i == 0:
            ans.append(n)
            continue
        if len(ans) > 0 and ans[-1] != n:
            ans.pop()
            cnt += 2
        else:
            ans.append(n)
    S = "".join(ans)
print(cnt)

N = eval(input())
zero = N.count("0")
one = N.count("1")
ans = min(zero, one) * 2
print(ans)

-S = eval(input()) -cnt = 0 -prev = 0 -while prev != len(S): -    prev = len(S) -    ans = [] -    for i, n in enumerate(S): -        if i == 0: -            ans.append(n) -            continue -        if len(ans) > 0 and ans[-1] != n: -            ans.pop() -            cnt += 2 -        else: -            ans.append(n) -    S = "".join(ans) -print(cnt) +N = eval(input()) +zero = N.count("0") +one = N.count("1") +ans = min(zero, one) * 2 +print(ans)