import sys
input=sys.stdin.readline
from collections import deque

d=deque(list(input().rstrip()))
d.append("2")
ans=0
r=0

while r<len(d):
    if len(d)<2:
        break
    if d[0]!=d[1] and d[0]!=2 and d[1]!=2:
        d.popleft()
        d.popleft()
        ans+=2
        r=0
    else:
        d.rotate(-1)
        r+=1

print(ans)