S = list(input())
tmp = len(S)
frag = True
while frag == True and len(S) != 0:
    i = 0
    frag = False
    while i < len(S)-1 and frag == False :
        if S[i] != S[i+1] :
            del S[i]
            del S[i]
            frag = True
        else:
            i += 1
print(tmp - len(S))
