S = list(input())
last_size = 0
size = len(S)
while True:
    for i in range(0, len(S)-1):
        if S[i] != S[i+1]:
            del S[i+1]
            del S[i]
            break
    if last_size == len(S) or len(S) == 0:
        break
    else:
        last_size = len(S)
print(size-len(S))