import Data.List

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

slv :: String -> Int
slv s | length s == 1 = 1
      | length s == 2 = length $ group s
      | otherwise = maximum [val1, val2]
  where val1 = slv' (tail s) (head s) 0 True
        val2 = slv' (drop 3 s) (head (drop 2 s)) 1 True

slv' :: String -> Char -> Int -> Bool -> Int
slv' [] c ret chk | chk = ret
                  | otherwise = 0
slv' str@(s:ss) c ret _ | s == c = slv' (drop 2 ss) newc (ret + 2) chk'
                        | otherwise = slv' ss s (ret + 1) True
  where (tmp1, tmp2) = splitAt 2 str
        chk' = length tmp1 == 2
        newc | tmp2 == "" = ' '
             | otherwise = head tmp1