import Control.Monad
import Data.List

solve :: [Int] -> Int
solve (x:xs) = x + sum (map conv xs)
  where conv x = 10 * ceiling (fromIntegral x / 10)

compareItems :: Int -> Int -> Ordering
compareItems i1 i2
  | c1 == c2 = EQ
  | c1 < c2 = LT
  | otherwise = GT
  where conv x = if x `mod` 10 == 0 then 10 else x `mod` 10
        c1 = conv i1
        c2 = conv i2

main :: IO ()
main = do
  items <- replicateM 5 readLn
  print . solve $ sortBy compareItems items