S = input()

def search_removable_point(s):
    return [i for i, (i1, i2) in enumerate(zip(s[:-1], s[1:])) if i1 != i2]

def remove_target_point(s, i):
    return s[:i] + s[i+2:]

def max_removed_point(s, i):
    removable_points = search_removable_point(s)
    if removable_points:
        return max([
            max_removed_point(remove_target_point(s, point), i + 1)
            for point in removable_points
        ])
    else:
        return i

print(max_removed_point(S, 0) * 2)
