import Control.Applicative ((<$>)) import Data.List (sortBy) import Data.Function (on) main :: IO () main = solve <$> getLine >>= print solve :: String -> Int solve = length . head . filter isPal . tail . sortBy (flip compare `on` length) . segments isPal :: Eq a => [a] -> Bool isPal = reverse >>= (==) segments :: [a] -> [[a]] segments = concat . scanr (\x y -> [x] : map (x:) y) []