import Control.Applicative
import Control.Monad

main :: IO ()
main = solve <$> replicateM 5 readLn >>= print

solve :: [Int] -> Int
solve = (-) <$> (sum . map f) <*> (maximum . filter (< 10) . map ((10 -) . (flip mod 10)))
  where
    f x = let (q, r) = divMod x 10
          in if x < 10 then 10 else if r > 0 then (q + 1) * 10 else x
