#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
double EPS=1e-10;
int INF=1e9;
struct dat{
      double d,v;
      dat(){}
      dat(double d,double v):d(d),v(v){}
      bool operator<(const dat &a)const{return d<a.d;}
};
int main(){
      int n,R;
      double x,y,r,v;
      while(cin>>R>>n&&(R||n)){
            vector<dat>V;
            REP(i,n){
                  cin>>x>>y>>r>>v;
                  V.PB((dat){sqrt(x*x+y+y)+r,v});
            }
            int ans=0;bool update=false;
            while(V.size()){
                  sort(ALL(V));
                  update=true;
                  REP(i,V.size()){
                        if(V[i].d>R){
                              update=false;
                              ans+=i;
                              REP(j,i+1){
                                    V.erase(V.begin());
                              }
                              break;
                        }
                  }
                  if(update){
                        ans+=V.size();
                        break;
                  }
                  REP(i,V.size()){
                        V[i].d-=V[i].v;
                  }
            }
            cout<<ans<<endl;
      }
}