
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

template<class T> T sqr(T x){
  return x*x;
}

const double eps=1e-9;

int main(){
  for(int R,N;cin>>R>>N,R;){
    int x0[100],y0[100],r[100],v[100];
    vector<int> rem(N);
    for(int i=0;i<N;i++){
      cin>>x0[i]>>y0[i]>>r[i]>>v[i];
      rem[i]=i;
    }
    int ans=0;
    for(int i=1;;i++){
      auto d=[&](int x){
	return sqrt(sqr(x0[x])+sqr(y0[x]))-i*v[x];
      };
      auto it=remove_if(begin(rem),end(rem),[&](int x){
	  return d(x)<=R+eps;
	});
      ans+=end(rem)-it;
      rem.erase(it,end(rem));
      if(rem.empty())break;
      auto cl=min_element(begin(rem),end(rem),[&](int a,int b){
	  return d(a)<d(b);
	});
      rem.erase(remove_if(begin(rem),end(rem),[&](int x){
	    complex<double> rp=polar(d(x),atan2(y0[x],x0[x])-atan2(y0[*cl],x0[*cl]));
	    return rp.real()+r[x]>=eps&&(rp.imag()+r[x])*(rp.imag()-r[x])<=eps;
	  }),end(rem));
    }
    cout<<ans<<endl;
  }
}