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 = []
    for i in range(1,len(s)):
        if s[i]==prev:
            prev = None
            ans += 2
            update = True
        elif prev is not None:
            l.append(prev)
        else:
            prev = s[i]
    s = "".join(l)
    if not update:
        break
        
print(ans)