s = list(input())
s_len = len(s)
i = 0
while True:
    if len(s) <= 1:
        break
    if s[i] == s[i+1] and len(s)==2:
        break
    if s[i] != s[i+1]:
        del s[i:i+2]
        i = 0
    else:
        i += 1
print(s_len-len(s))