S = [] 
def f1():
    global S
    i = 1
    while i < (len(S) - 1):
        if S[i] != S[i + 1]:
            if S[i - 1] != S[i + 2]:
                del S[i:i + 2]
                return True

        i += 1
    
    return False

def f2():
    global S
    i = 1
    while i < (len(S) - 1):
        if S[i] != S[i + 1]:
            del S[i:i + 2]
            return True

        i += 1
    
    return False


def f3():
    global S
    if 2 <= len(S):
        if S[0] != S[1]:
            del S[0:2]
            return True
    
    return False

def f4():
    global S
    if 2 <= len(S):
        b = len(S) - 1
        if S[b] != S[b - 1]:
            del S[b - 1:]
            return True
    
    return False


n = 0
S = list(input().rstrip())
while 0 < len(S):
    result = f1()
    if result:
        n += 1
        continue

    result = f2()
    if result:
        n += 1
        continue

    result = f3()
    if result:
        n += 1
        continue

    result = f4()
    if result:
        n += 1
        continue

    break


print(n * 2)
