import Control.Monad
import Control.Applicative
import Data.List

roundUp :: Int -> Int
roundUp a = case a `mod` 10 of
  0 -> a
  n -> a + 10 - n

main :: IO ()
main = do
  ints <- replicateM 5 (readLn :: IO Int)
  let pairs = (\a -> (a, a `mod` 10)) <$> ints
  let sorted = sortBy (\a b -> compare (snd a) (snd b)) pairs
  let rest = head $ filter (\t -> snd t /= 0) $ sorted
  putStrLn $ show $ (foldl (\acc o -> acc + roundUp o) 0 ints) - (10 - snd rest)
