S = list(input())
ans = 0
for _ in range(len(S)):
    check = S[0]
    tmp = ans
    for i in range(1,len(S)):
        if check != S[i]:
            count = 1
            for _ in range(len(S)):
                if i-1-count > 0 and i+count < len(S):
                    if S[i-1-count] != S[i+count]:
                        count += 1
                    else:
                        break
                else:
                    break
            ans += 2 * count
            del S[i-count:i+count]
            break
        check = S[i]
    if len(S) == 0:
        break
    if tmp == ans:
        break
print(ans)