{-# LANGUAGE MultiWayIf #-}

import Data.List (group)

inverseC c = if c == '0' then '1' else '0'

inverseS = map inverseC

solve l s m =
  let ss = group s
      ls = length ss
  in if | ls == 1 -> m
        | otherwise ->
            if (length.head) ss < (length.last) ss
              then
                solve l (head ss++concatMap inverseS (tail ss)) $ min m (l-(length.head)ss)
              else
                solve l (concatMap inverseS (init ss)++last ss) $ min m (l-(length.last)ss)

main :: IO ()
main = do
  s <- getLine :: IO String
  print $ solve (length s) s (length s)
