s=gets.chomp n=s.size puts (0..n-2).reduce(1){|x,i| break x if n-i<=x (x+1..n-1).reduce(x){|y,j| i+j>n and break y t=s[i,j] t==t.reverse ? j : y } }