A = gets.to_i
B = gets.to_i
C = gets.to_i
D = gets.to_i
E = gets.to_i

number = []

[A, B, C, D, E].permutation(5).each do |abcde|
  sum = 0
  abcde.each_with_index do |n, i|
    sum += n
    if i != 4 and sum%10 != 0
      sum = sum + (10 - sum%10)
    end
  end
  number << sum
end

p number.min