#coding: utf-8 ##yuki_273 import sys def palindrome(string): return 1 if string==string[::-1] else 0 s=raw_input() n=len(s) if n==2 and s[0]==s[1]: print 1 sys.exit() res=0 for i in xrange(n): for j in xrange(n): if palindrome(s[i:n-j])==1: res_temp=len(s[i:n-j]) if res_temp>res: res=res_temp if res==n: print res-2 else: print res