s = input() count_ls = [] for i in range(1, len(s) - 1): count = 1 for c1, c2 in zip(s[i - 1::-1], s[i + 1:]): if c1 == c2: count += 2 count_ls.append(count) for i in range(len(s) - 1): count = 0 for c1, c2 in zip(s[i::-1], s[i + 1:]): if c1 == c2: count += 2 count_ls.append(count) print(max(count_ls))