a, b, c, d, e = readlines.map &:to_i
array = [a, b, c, d, e]

def calculate(v)
  i = v % 10
  (10 - i) % 10
end

if array.uniq.size == 1
  puts array.inject { |sum, i| sum.ceil(-1) + i.ceil(-1) }
else
  array.sort! { |x, y| calculate(x) <=> calculate(y) }
  total = array.inject { |sum, i| sum.ceil(-1) + i.ceil(-1) }
  puts total - calculate(array.last)
end
