orders = []
5.times do
  orders << STDIN.gets.chomp.to_i
end

min_time = 643

orders_permutation = orders.permutation(5).to_a.uniq

orders_permutation.length.times do |i|
  current_time = 0

  orders_permutation[i].each do |o|
    ceil = current_time % 10
    current_time = current_time - ceil + (ceil.zero? ? 0: 10)
    current_time += o
  end

  if current_time < min_time
    min_time = current_time
  end
end

puts min_time