main :: IO()
main = do
    a <- readLn
    b <- readLn
    c <- readLn
    d <- readLn
    e <- readLn
    print $ solve [a,b,c,d,e]



solve :: [Int] -> Int
solve ls = sum summing + last changeLs
    where changeLs = firstSmall ls []
          summing = map floorUp (init changeLs)

--1の位が最も小さい数字を一番後ろにに持っていく。ただし０は１０と扱う。
firstSmall :: [Int] -> [Int] -> [Int]
firstSmall ls resultLs
    | ls == []							= resultLs
    | resultLs == []					= firstSmall (tail ls) [head ls]
    | otherwise 						= if (getOne $ head ls) > (getOne $ last resultLs)
												then firstSmall (tail ls) ((head ls):resultLs)
												else firstSmall (tail ls) (resultLs ++ [(head ls)])

--１の位を出力。ただし0だったら10を返す。
getOne :: Int -> Int
getOne num = if (mod num 10) == 0 then 10 else mod num 10 

--１０の位までで切り上げ。
floorUp :: Int -> Int
floorUp num = if mod num 10 == 0 then num else num + 10 - (mod num 10)