# coding: utf-8
# Your code here!

import copy

string = [*input()]

concat_string = copy.copy(string)
count = 0
while True:
    num_delete = 0
    flags_delete = [False] * len(string)
    
    i = 0
    j = 1
    while i < len(concat_string) - 1:
        if concat_string[i] != concat_string[j]:
            flags_delete[i] = True
            flags_delete[j] = True
            num_delete += 2
            
            if i == 0:
                i = j + 1
                j = i + 1
            else:
                i = i - 1
                j = j + 1
        else:
            i = j
            j = i + 1
           
    if num_delete == 0:
        break
    
    count += num_delete
    concat_string = [concat_string[i] for i in range(len(concat_string)) if flags_delete[i] == False]

print(count)
        
        