# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end


arr = []
inputs.each do |a_i|
  arr << [a_i[0], (10 - a_i[0]%10)%10]
end

pd arr
arr.sort_by! {|e_i| e_i[1]}
pd arr

ans = 0
arr.size.times do |i|
  if i == arr.size - 1
    ans += arr[i][0]
  else
    ans += arr[i][0] + arr[i][1]
  end
end

puts ans