def gap i
  c = 0
  until i % 10 == 0
    i = i.succ
    c += 1
  end
  return c
end

a = [ ]
a.push gets.to_i # donburi
a.push gets.to_i # kare-
a.push gets.to_i # pasta
a.push gets.to_i # ra-men
a.push gets.to_i # hanba-gu

a.sort_by!{ |t| gap(t) }

sum = a.inject(:+)
a.pop
sum += a.map{ |x| gap(x) }.inject(:+)

p sum
