import Data.List

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

main = do
  s <- getLine

  let col = (map length (collect s))
  let acc = scanl (+) 0 col
  let n = length s

  print $ maximum $ f col acc n

  where
    f _ [] _ = []
    f [] _ _ = []
    f (x:xs) (y1:y2:ys) n = min (x+y1) (x+(n-y2)) : (f xs (y2:ys) n)
