s = list(str(input()))
ans = 0
drop = False
l = 0
while l <= len(s) - 2:
    if drop == False:
        if s[l] != s[l + 1]:
            ans += 2
            del s[l:l + 2]
            drop = True
        else:
            l += 1
    while drop == True and len(s) >= 2:
        if 0 <= l:
            l -= 1
        if s[l] != s[l + 1]:
            ans += 2
            del s[l:l + 2]
        else:
            drop = False
            l += 1
print(ans)