S = list(input())
N = len(S)

while(True):
    if len(S) <= 1:
        break

    popped = False
    for i in range(len(S)-1):
        if S[i] != S[i+1]:
            S.pop(i)
            S.pop(i)
            popped = True
            break

    if not popped:
        break

print(N-len(S))