# input
menu = []
5.times do |i|
  menu.push(gets.chomp.to_i)
end
  
# main
ans = []
menu.permutation.to_a.each do |v|
  tmp = 0
  5.times do |i|
    tmp += v[i]
    if tmp % 10 != 0 and i != 4 then
      tmp += 10 - tmp % 10
    end
  end
  ans.push(tmp)
end
  
# output
puts ans.min
