#include <iostream>
#include <algorithm>
#include <cmath>
#include <complex>
#include <vector>
using namespace std;
typedef complex<double> P;
const double eps = 1e-8;


bool equals(double a, double b) {
  return abs(a-b) < eps;
}

double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}
double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}
double norm(P a) {
  return a.real()*a.real() + a.imag()*a.imag();
}
double abs(P a) {
  return sqrt(norm(a));
}
double getDistanceLP(P s1, P s2, P p) {
  return fabs(cross(s2 - s1, p - s1)/abs(s2 - s1));
}
double getDistanceSP(P s1, P s2, P p) {
  if(dot(s2 - s1, p - s1) < 0.0) return abs(p - s1);
  if(dot(s1 - s2, p - s2) < 0.0) return abs(p - s2);
  return getDistanceLP(s1, s2, p);
}

struct UFO {
  double r, rad, d, v;
  UFO() {}
  UFO(P p, double r, double v)
    : r(r), rad(atan2(p.imag(),p.real())), d(abs(p)), v(v) {}
  bool operator < (const UFO &u) const {
    if(d != u.d) return d < u.d;
    return false;
  }
  void move() {
    d -= v;
  }
  P getP() {
    return P(d*cos(rad), d*sin(rad));
  }
};

int R, N;
vector<UFO> V;

int solve() {
  int in;
  in = 0;

  while(V.size()) {
    for(vector<UFO>::iterator it = V.begin(); it != V.end();) {
      it->move();
      if(equals(it->d, R) || it->d < R) {
	it = V.erase(it);
	++in;
      } else {
	++it;
      }
    }
    sort(V.begin(), V.end());
    P a(0,0), b((V[0].getP())*10000.0);
    for(vector<UFO>::iterator it = V.begin(); it != V.end();) {
      double d = getDistanceSP(a,b,it->getP());
      if(equals(d, it->r) || d < it->r) {
	it = V.erase(it);
      } else {
	++it;
      }
    }
  }
  return in;
}

int main() {
  while(cin >> R >> N && (R | N)) {
    V.clear();
    for(int i = 0; i < N; ++i) {
      double r, v;
      P p;
      cin >> p.real() >> p.imag() >> r >> v;
      V.push_back(UFO(p,r,v));
    }
    cout << solve() << endl;
  }
  return 0;
}