def solve(): s = input() result = 0 for i in range(1, len(s)): total = 0 for c1, c2 in zip(s[i-1::-1], s[i:]): total += (c1 == c2)*2 if result < total: result = total total = 1 for c1, c2 in zip(s[i-1::-1], s[i+1:]): total += (c1 == c2)*2 if result < total: result = total print(result) if __name__ == "__main__": solve()