#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
using namespace std;
typedef complex<double> P;

struct ufo
{
  P p;
  int r;
  int v;

  bool operator<(const ufo& that) const
  {
    return abs(p) < abs(that.p);
  }
};

struct invaded
{
  int R;
  invaded(int r) : R(r) {}
  bool operator()(const ufo& u) const
  {
    return abs(u.p) <= R;
  }
};

struct move
{
  ufo operator()(const ufo& u) const
  {
    ufo v;
    v.r = u.r;
    v.v = u.v;
    const P e = u.p / abs(u.p);
    v.p = u.p - double(u.v)*e;
    return v;
  }
};

double cross(const P& p, const P& q)
{
  return p.real()*q.imag() - p.imag()*q.real();
}

double distance_point_line(const P& p, const pair<P,P>& line)
{
  const P a = p - line.first;
  const P b = line.second - line.first;
  return abs(cross(a, b)) / abs(b);
}

double dot(const P& p, const P& q)
{
  return p.real()*q.real() + p.imag()*q.imag();
}

struct hit
{
  P p;
  hit(const P& a) : p(a) {}
  bool operator()(const ufo& u) const
  {
    static const P orig(0.0, 0.0);
    const double d = distance_point_line(u.p, make_pair(orig, p));
    return d <= u.r;
  }
};

int main()
{
  int R, N;
  while (cin >> R >> N && R != 0) {
    vector<ufo> us;
    for (int i = 0; i < N; i++) {
      ufo u;
      cin >> u.p.real() >> u.p.imag() >> u.r >> u.v;
      us.push_back(u);
    }

    int ans = 0;
    for (int t = 1; t <= 100 && !us.empty(); t++) {
      vector<ufo> vs;
      transform(us.begin(), us.end(), back_inserter(vs), move());
      for (vector<ufo>::iterator it = us.begin(), jt = vs.begin(); jt != vs.end(); ++it) {
        if (dot(it->p, jt->p) < 0) {
          jt = vs.erase(jt);
          ++ans;
        } else {
          ++jt;
        }
      }
      if (vs.empty()) {
        break;
      }
      us = vs;

      vector<ufo>::iterator it = remove_if(us.begin(), us.end(), invaded(R));
      ans += distance(it, us.end());
      us.erase(it, us.end());

      it = min_element(us.begin(), us.end());
      const P p = it->p;
      us.erase(it);
      us.erase(remove_if(us.begin(), us.end(), hit(p)), us.end());
    }
    cout << ans << endl;
  }
  return 0;
}