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

ar_0 = []
count = 0
while count < ar.length do
  if (ar[count] % 10) == 0 then
    ar_0.push(ar[count])
    ar.delete_at(count)
  end
  count += 1
end
ar = ar.sort_by {|num| num % 10}.reverse

sorted_ar = []
sorted_ar.push(ar_0).push(ar).flatten!

ans = 0
time = 0

for i in 0..4 do
  ans = time + sorted_ar[i]
  time += sorted_ar[i]
  if (time % 10) != 0 then
    time = ((time / 10) * 10) + 10
  end
end

puts ans
