import Data.List
import Control.Monad
main :: IO ()
main = do
  ae <- replicateM 5 readLn
  let b = span (\x -> x `mod` 10 == 0) $ sortOn (`mod` 10) ae
  let c = head (snd b) : map (\x -> (x `div` 10 + 1) * 10) (tail $ snd b)
  print $ sum (fst b) + sum c

