import copy

s = input()

tmp = ""
count = 0
while(True):
    flag = False
    for i in range(len(s)-1):
        if(flag == True): flag = False
        elif(s[i] != s[i+1]):
            count += 2
            flag = True
        else: tmp += s[i]

    if(flag == False and len(s) != 0): tmp += s[len(s)-1]
    if(s == tmp): break

    s = copy.deepcopy(tmp)
    tmp = ""

print(count)