a = gets.chomp
b = gets.chomp
c = gets.chomp
d = gets.chomp
e = gets.chomp

arr = [a, b, c, d, e]
m = arr.map{|elm| elm[-1]}
m.delete_if{|elm| elm =='0'}
m = m.map(&:to_i).min
m = arr.find{|elm| elm[-1] == m.to_s}

idx = arr.index(m)
arr.delete_at(idx)

sum = 0
arr.each do |e|
  begin
    e = e - 10
    sum += 10
  end until	e < 0	
end
  
puts sum + m