import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s = input()
n = len(s)
prev = s[0]
ans = 0
l = s
while l:
    update = False
    l = []
    i = 1
    while i<len(s):
        if s[i-1]!=s[i]:
            l.append(i-1)
            l.append(i)
            update = True
            ans += 2
            i += 2
        else:
            i += 1
    s = "".join(s[i] for i in range(len(s)) if i not in l)
    if not update:
        break
        
print(ans)