import copy

s = input().split()[0]

def get_kouho_list(box_list):
    kouho_list = []
    for i, color in enumerate(box_list[:-1]):
        if box_list[i] != box_list[i+1]:
            kouho_list.append((i, i+1))
    return kouho_list

def tansaku(now_box_list, koremade_step):
    kouho_list = get_kouho_list(now_box_list)
    for kouho in kouho_list:
        next_box_list = copy.copy(now_box_list)
        del next_box_list[kouho[0]:kouho[1]+1]
        tansaku(next_box_list, koremade_step + 1)
    global max_step
    if koremade_step > max_step:
        max_step = koremade_step
    return

max_step = 0
tansaku(list(s), 0)
print(max_step * 2)
