def kaibun_parse(str,l) str1 = str[0..l-1] l.times{|i| tmp = str1[i..l-1] if tmp == tmp.reverse && tmp != str return tmp end } end def kaibun_max(str,n) if n == 0 return "" else tmp = [kaibun_max(str,n-1),kaibun_parse(str,n)] return tmp.max{|a,b|a.size <=> b.size} end end s = gets.chomp puts kaibun_max(s,s.size).size