dishes = []
lags = []

5.times do |i|
  dishes << gets.to_i
end

for i in 0..4
  lags << ((dishes[i] % 10 == 0) ? 0 : (10 - (dishes[i] % 10)))
end

puts dishes.inject(:+) + lags.sort!.inject(:+) - lags[4]