### main

while true
  rlimit, n = gets.strip.split(' ').map{|s| s.to_i}
  break if rlimit == 0 && n == 0

  rlimit2 = rlimit ** 2

  ufos = []

  n.times.each do
    x0, y0, r, v = gets.strip.split(' ').map{|s| s.to_i}

    d2 = x0 ** 2 + y0 ** 2
    d = Math.sqrt(d2)
    vx = -x0.to_f * v / d
    vy = -y0.to_f * v / d
    ufos << [x0, y0, d2, x0, y0, vx, vy, r * r]
  end

  count = 0

  while ! ufos.empty?
    ufos0 = ufos.sort{|a, b| a[2] <=> b[2]}
    min_u = nil

    for u0 in ufos0
      if u0[2] <= rlimit2
        count += 1
        ufos.delete(u0)
        next
      end

      if min_u.nil?
        min_u = u0
        lx = min_u[3]
        ly = min_u[4]
        lxy2 = lx ** 2 + ly ** 2
        ## lazer: ly * x - lx * y = 0
        ufos.delete(u0)
        next
      end

      ld2 = (ly * u0[0] - lx * u0[1]) ** 2
      if ld2 <= u0[7] * rlimit2 && lx * u0[0] + ly * u0[1] > 0
        ufos.delete(u0)
      end
    end

    for u in ufos
      u[0] += u[5]
      u[1] += u[6]
      u[2] = u[0] ** 2 + u[1] ** 2
    end

    #p ufos
  end

  puts count
end