
cooking_time = []
5.times do
    cooking_time.push(gets.chomp.to_i)
end

last = 10
last_order = 10
5.times do |i|
    if cooking_time[i] % 10 < last and cooking_time[i] % 10 != 0
        last = cooking_time[i] % 10
        last_order = i
    end
end

ans = 0
5.times do |i|
    if i == last_order
        next
    end
    ans += cooking_time[i]
    if ans % 10 != 0
        ans += (10 - ans % 10)
    end
end

ans += cooking_time[last_order]

puts ans
