s = list(input())

rm_count=0
rm_index=[]
while True:
    for i in range(len(s)-1):
        if i in rm_index:
            continue
        if s[i] != s[i+1]:
            rm_count=rm_count+2
            rm_index+=[i,i+1]
            #print("DEBUG: {}, {}, count: {}".format(s[i],s[i+1],rm_count))

    for i in sorted(rm_index, reverse=True):
        s.pop(i)
    rm_index=[]
    if len(set(s)) == 1 or len(s) == 0:
        break
print(rm_count)
