S = list(input())
N = len(S)
C = [0] * N
L = [None] * N

C[0] = 0
L[0] = [S[0]]
for i in range(1, N):
    if len(L[i-1]) > 0 and L[i-1][-1] != S[i]:
        C[i] = C[i-1] + 2
        L[i] = L[i-1][:-1]
    else:
        C[i] = C[i-1]
        L[i] = L[i-1] + [S[i]]
print(C[-1])