import Control.Monad
import Data.Char

main = do
    s <- getLine
    putStrLn $ show $ solve s

solve :: String -> Int
solve s = min (doit 0 s) (doit 1 s)
  where
    doit p []    = 0
    doit p (h:t) = (abs (digitToInt h - p)) + doit (1 - p) t