import qualified Data.ByteString.Char8 as BS
import Control.Monad

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

cc :: Char -> [String] -> [[String]]
cc c [] = [[[c]]]
cc c xs = [((c:(head xs)) : (tail xs)), ([c]:xs) ]

usecc :: Char -> [[String]] -> [[String]]
usecc c [] = []
usecc c (xs:xss) = (cc c xs) ++ (usecc c xss)

neiborDifferent :: [String] -> Bool
neiborDifferent [x] = True
neiborDifferent (x:x2:xs) | x == x2 = False
                          | otherwise = neiborDifferent (x2:xs)

calc :: String -> [[String]] -> [[String]]
calc [] xss = xss
calc (c:cs) [] = calc cs [[[c]]]
calc (c:cs) xss = calc cs xss'
  where
    xss' = usecc c xss

main = do
  [cs] <- getString
  print $  maximum (map length (filter (neiborDifferent) (calc cs [])))

