### 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.to_f, y0.to_f, d2, x0, y0, vx, vy, r * r]
  end

  count = 0
  t = 0

  while ! ufos.empty?
    #puts "t=#{t}"

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

    for u0 in ufos0
      #p ['u0'] + u0

      if u0[2] <= rlimit2
        count += 1
        ufos.delete(u0)
        #puts "  d2=#{u0[2]}, rlimit2=#{rlimit2}: enter (delete)"
        next
      end

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

      ld2 = (ly * u0[0] - lx * u0[1]) ** 2
      if ld2 <= u0[7] * lxy2 && lx * u0[0] + ly * u0[1] > 0
        ufos.delete(u0)
        #puts "  dr2=#{ld2/lxy2} <= r2=#{u0[7]} : hit (delete)"
      end
    end

    t += 1

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

  puts count
end