def next_top(idx):
    jump = 1
    if idx + jump == l:
            return -1
    while(exist[idx+jump]==0):
        jump = jump +1
        if idx + jump == l:
            return -1
    return idx + jump

def next_bottom(idx):
    jump = 1
    while(exist[idx+jump]==0):
        jump = jump -1
        if idx - jump == -1:
            return -1
    return idx + jump

# 文字列の入力
s = input()
l = len(s)
exist = [1]*l
removal_count = 0
max_removal = l // 2
8
top_idx = 1
bottom_idx = 0

while removal_count != max_removal:
    if s[bottom_idx] != s[top_idx]:
        removal_count = removal_count +1
        exist[bottom_idx] = 0
        exist[top_idx] = 0
        if next_top(top_idx) < 0:
            break
        elif next_bottom(bottom_idx) < 0:#双方上へずらす
            if next_top(next_top(top_idx))>=0:
                bottom_idx = next_top(top_idx)
                top_idx =  next_top(bottom_idx) 
            else:
                break
        else:
            top_idx = next_top(top_idx)
            bottom_idx = next_bottom(bottom_idx)
    else:
        if next_top(next_top(top_idx))>=0:
            bottom_idx = next_top(top_idx)
            top_idx =  next_top(bottom_idx)
        else:
            break
print(removal_count *2)
