#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int R,n;
  while(cin>>R>>n, R+n){
    double x[n], y[n], r[n];
    double dx[n], dy[n];
    bool   f[n];
    int ans = 0;
    REP(i,n){
      double v;
      cin>>x[i]>>y[i]>>v>>r[i];
      double d = sqrt(x[i]*x[i] + y[i]*y[i]);
      dx[i] = - v * (x[i]/d);
      dy[i] = - v * (y[i]/d);
      f[i] = true;
    }
    bool flag = true;
    while(flag){
      double dmin = 1e20;
      int idx = -1;
      flag = false;
      REP(i,n){
        if(f[i]){
          x[i] += dx[i];
          y[i] += dy[i];
          flag = true;

          double d = x[i]*x[i] + y[i]*y[i];
          if(d <= R*R){
            //printf("%d is into R\n",i);
            f[i] = false;
            ans++;
          }else{
            if(d < dmin){
              dmin = d;
              idx = i;
            }
          }
        }
      }
      if(idx != -1){
        double xx = x[idx];
        double yy = y[idx];
        double a,b;
        double dd = sqrt(xx*xx+yy*yy);
        double dxx = xx / dd;
        double dyy = yy / dd;
        a = yy; b = -xx;
        //printf("target = %d: ",idx);
        REP(i, n){
          if(f[i]){
            double dist = abs(a*x[i] + b*y[i]) / sqrt(a*a + b*b);
            double vx = dxx * x[i];
            double vy = dyy * y[i];

            if(idx == i || (vx * xx > 1e-10 || (vy * yy > 1e-10)) && dist <= r[i]){
              f[i] = false;
              //putchar('x');
            }else{
              //putchar(' ');
            }
            //printf("%d",i);
          }
        }
        //puts("");
      }
    }
    cout << ans << endl;
  }
  return 0;
}