s = list(input()) l = len(s) ret = 0 for ti in range(l): for tj in range(ti,l): i = ti; j = tj tmp = 0 while (i <= j): if s[i] == s[j]: if i == j: tmp += 1 else: tmp += 2 i += 1; j -= 1 ret = max(ret,tmp) print(ret)