import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as BS

f 0 n         = n
f x n
   |m==5&&mm>4= f (d+1) (n+10-m)
   | m < 6    = f d (n + m)
   |otherwise = f (d+1) (n+10-m)
   where
      (d,m) = divMod x 10
      mm    = mod d 10 

countBill n = f n 0

main = do
   n <- fst . fromJust . BS.readInteger <$> BS.getLine
   putStrLn $ show $ countBill n