S=str(input())
num=0
def left(S,num):
    ini=S[0]
    for i in range(len(S)):
        if i==0:
            continue
        if ini==S[i]:
            continue
        if ini!=S[i]:
            g=S[:i-1]
            h=S[i+1:]
            num+=1
            return (g+h,num)
    return ("",num)
def right(S,num):
    S=S[::-1]
    ini=S[0]
    for i in range(len(S)):
        if i==0:
            continue
        if ini==S[i]:
            continue
        if ini!=S[i]:
            g=S[:i-1]
            h=S[i+1:]
            num+=1
            return ((g+h)[::-1],num)
    return ("",num)  
for i in range(len(S)):
    S,num=left(S,num)
    if S=="":
        break
    S,num=right(S,num)
    if S=="":
        break
print(num*2)
    