
collect [] = []
collect list@(x:xs) = a : (collect b)
  where
    (a,b) = span (== x) list

main = do
  s <- getLine

  print $ maximum $ f (map length (collect s))

  where
    f xs = g $ 0 : xs
    g (a:b:[]) = [b]
    g (a:b:c:xs) = (min (a+b) (b+c)) : g (b:c:xs)
