cookingTimes = 5.times.map{gets.to_i}
cookingTimeDiffs = cookingTimes.map{|v| v%10 == 0 ? 10 : v%10}
cookingtimeDiffMinIndexNumber = cookingTimeDiffs.index(cookingTimeDiffs.min)
sumTime = 0
cookingTimes.each do |value|
  next if value == cookingTimes[cookingtimeDiffMinIndexNumber]
  sumTime += value
  sumTime += 10 - value%10 if value%10 != 0
end
puts sumTime + cookingTimes[cookingtimeDiffMinIndexNumber]