a = []
5.times do
	a << gets.to_i
end
a.sort!
sum = 1000
a.permutation(5).each do |per|
  tmp = 0
  per.each do |i|
    if tmp % 10 == 0
      tmp += i
    else
      while tmp % 10 != 0
        tmp += 1
      end
      tmp += i
    end
  end
  sum = tmp if tmp < sum
end
puts sum
