
last = 0
time = 0
5.times do | i |
    t = gets.chomp.to_i
    mod = t % 10
    if mod != 0 then
        mod = 10 - mod
    end
    if last < mod then
        last = mod
    end

    time += t + mod
end

puts time - last

