#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
using namespace std;
#define X first
#define Y second

typedef long double ld;
typedef long long ll;
typedef ld P_type;
//typedef pair<P_type,P_type> P;
typedef pair<int,int> P;
const ld INF = 1e39;
const ld EPS = 1e-8;
const ld  PI = acos(-1);

P operator-(P a,P b) {
  return P(a.X - b.X, a.Y - b.Y);
}

P_type out_pro(P a,P b) {
  return (a.X * b.Y - b.X * a.Y);
}

P_type in_pro(P a,P b){
  return (a.X * b.X + a.Y *b.Y);
}

P_type pow_len(P a) {
  return a.X * a.X + a.Y * a.Y;
}

ld len(P a){
  return sqrt(ld(pow_len(a)));
}

struct UFO{
  UFO(){};
  UFO(ld xx,ld yy,int rr,int vv){
    pos.X=xx;
    pos.Y=yy;
    r=rr;
    v=vv;
  }
  P pos;
  int r,v;
};
ld distance(UFO a,int time){
  return len(a.pos)-double(time*a.v);
}
int t;//now time
bool operator<(UFO a,UFO b){
  return distance(a,t)<distance(b,t);
}


int R;
vector<UFO> ufos;
void init(){
  t=1;
  R=0;
  ufos.clear();
}

bool input(){
  int n;
  cin>>R>>n;
  if(R==0&&n==0)return false;
  for(int i=0;i<n;i++){
    ld x,y;
    int r,v;
    cin>>x>>y>>r>>v;
    ufos.push_back(UFO(x,y,r,v));
  }
  return true;
}

bool shot(UFO target,UFO aa){
  P tar = target.pos;
  P a = aa.pos;
  ld dist = abs(out_pro(tar,a));
  return (aa.r > dist/len(a))&&(in_pro(tar,a)>=0)&&(distance(aa,t)>R);
}


int solve(){
  int res=0;
  while(ufos.size()!=0){
    vector<UFO> tmp;
    sort(ufos.begin(),ufos.end());
    UFO target;
    bool j=false;
    for(int i=0;i<ufos.size();i++){
      if(distance(ufos[i],t)<=R){
        res++;
      }else{
        if(j){
          if(!shot(target,ufos[i])){
            tmp.push_back(ufos[i]);
          }
        }else{
          target=ufos[i];
          j=true;
        }
      }
    }
    ufos=tmp;t++;
  }
  return res;
}

int main(){
  while(init(),input()){
    cout<<solve()<<endl;
  }
}