import Data.List

main :: IO ()
main = do
  s <- getLine
  print $ solve s

solve :: String -> Int
solve xs = solve' 1 (length xs) xs

solve' :: Int -> Int -> String -> Int
solve' i j [_] = 0
solve' i j (x:y:zs)
  | x == y = sol
  | otherwise = maximum [i, j, sol]
  where sol = solve' (i + 1) (j - 1) (y:zs)

