l = 5.times.map{gets.chomp}.sort_by{|c| c[-1]}.map(&:to_i)
min = l.select{|n| n%10!=0}[0] || 0
sum,f = 0,false
l.each do |n|
  if (n != min and n%10 != 0) or f
    n = n/10*10 + 10
  end
  f = true if n == min
  sum += n
end
p sum