dish = []
dish.push(gets.chomp.to_i)
dish.push(gets.chomp.to_i)
dish.push(gets.chomp.to_i)
dish.push(gets.chomp.to_i)
dish.push(gets.chomp.to_i)

sum = 0
max_kiriage = 0
max_kiriage_index = 10
5.times do |i|
  if dish[i] % 10 == 0
    kiriage = 0
  else
    kiriage = 10 - dish[i] % 10
  end
  if max_kiriage <= kiriage
    max_kiriage = kiriage
    max_kiriage_index = i
  end
end

5.times do |i|
  if i == max_kiriage_index
    next
  elsif dish[i] % 10 != 0
    sum += dish[i] + 10 - dish[i] % 10  
  else
    sum += dish[i]
  end
end

puts sum + dish[max_kiriage_index]
  