until (l = gets.to_i).zero?
  data = 12.times.map {gets.split.map(&:to_i)}
  month_number = "NA"
  
  acc = 0
  data.each_with_index do |mn, i|
    acc += mn[0] - mn[1]
    if acc >= l
      month_number = i + 1
      break
    end
  end
  
  puts month_number
end
