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

readInts = map read . words <$> getLine :: IO [Int]

solve xs
  | all ((==0) . (`mod`10)) xs = sum $ map ((*10) . (`div`10) . (+9)) xs
  | otherwise = (sum $ map ((*10) . (`div`10) . (+9)) xs) - 10 + (minimum $ filter (/=0) $ map (`mod`10) xs)

main = replicateM 5 readLn >>= print . solve
