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, val3, val4]
  where val1 = slv' (tail s) (head s) 1
        val2 = slv' (drop 3 s) (s !! 2) 2
        ss = reverse s
        val3 = slv' (tail ss) (head ss) 1
        val4 = slv' (drop 3 ss) (ss !! 2) 2
        

slv' :: String -> Char -> Int -> Int
slv' "" _ ret = ret
slv' str@(s:ss) c ret | s == c && ss == [] = 0
                      | s == c && tmp2 == "" = ret + 1
                      | s == c = slv' (drop 3 str) newc (ret + 2)
                      | otherwise = slv' ss s (ret + 1)
  where tmp2 = drop 2 str
        newc | tmp2 == "" = ' '
             | otherwise = head tmp2