def int
  gets.to_i
end

def ints
  gets.split.map(&:to_i)
end

A = int
B = int
C = int
D = int
E = int

times = [A, B, C, D, E]

min_time = Float::INFINITY
times.permutation(times.size) do |tt|
  ct = 0
  tt.each.with_index do |t, i|
    ct += t
    if i < tt.size - 1
      ct += (ct % 10 == 0) ? 0 : 10 - (ct % 10)
    end
  end
  min_time = [min_time, ct].min
end

puts min_time
