#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


// #define MOD 1000000007LL
// #define EPS 1e-8
// static const int INF=1<<24;

#define double long double
const double EPS = 1e-8;
const double INF = 1e12;
const double PI = asin(0.5)*6;
typedef complex<double> P;

#define X real()
#define Y imag()

#define Curr(P,i) P[(i)%P.size()]
#define Next(P,i) P[(i+1)%P.size()]
#define Prev(P,i) P[(i+P.size()-1)%P.size()]

namespace std{
  bool operator<(const P a,const P b){
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}
//gaiseki
double cross(const P a,const P b){
  return (conj(a)*b).imag();
}
//naiseki
double dot(const P a,const P b){
  return (conj(a)*b).real();
}
// TODO make graph (20)
int ccw(P a,P b,P c){
  b-=a;
  c-=a;
  if(cross(b,c)>0)    return +1;//counter clockwise
  if(cross(b,c)<0)    return -1;//clockwise
  if(dot(b,c)<0)      return +2;// c--a--b
  if(norm(b)<norm(c)) return -2;// a--b--c
                      return  0;// a--c--b(or b==c)
}

struct L : public vector<P>{
  L(){};
  L(const P a,const P b){
    push_back(a),push_back(b);
  }
};
typedef L S;
typedef vector<P> G;

struct C{
  P p;double r;
  C(){};
  C(const P p,double r): p(p),r(r){}
};



//??´?????¨????????¢???
//??????????????????????????????????????????
P projection(L a,P p){
  double t = dot(p-a[0],a[0]-a[1])/norm(a[0]-a[1]);
  return a[0] + t*(a[0]-a[1]);
}
//???????§°??????
// P reflection(L a,P p){
  // return p + 2.0 * (projection(a,p)-p);
// }




//????????????
//TODO CP(??????) CL CS (0)
bool isCrossLL(L a,L b){
  return 
    abs(cross(a[1]-a[0],b[1]-b[0])) > EPS
    || abs(cross(a[1]-a[0],b[0]-a[0])) < EPS ;
}
bool isCrossLS(L a,S b){
  return 
    cross(a[1]-a[0],b[0]-a[0]) 
    * cross(a[1]-a[0],b[1]-a[0]) < EPS;
}
bool isCrossLP(L l,P p){
  return abs(cross(l[1]-p,l[0]-p)) < EPS;
}
bool isCrossSS(S a,S b){
  return
    ccw(a[0],a[1],b[0])
    * ccw(a[0],a[1],b[1]) <= 0
    &&
    ccw(b[0],b[1],a[0])
    * ccw(b[0],b[1],a[1]) <= 0;
}
bool isCrossSP(S a,P p){
  return abs(a[0]-p)+abs(a[1]-p)-abs(a[0]-a[1]) < EPS;
}


// ?????¢ CP CL CS ???(distXP(x,c.p)-c.r)
double distPP(P a,P b){
  return abs(a-b);
}
double distLP(L a,P p){
  return abs(p-projection(a,p));
}
double distLL(L a,L b){
  return isCrossLL(a,b) ? 0 : distLP(a,b[0]);
}
double distLS(L a,S b){
  return isCrossLS(a,b) ? 0 : min(distLP(a,b[0]),distLP(a,b[1]));
}
// double distSP(S a,P p){
  // const P r = projection(a,p);
  // return isCrossSP(a,r) ? abs(p-r) : min(abs(a[0]-p),abs(a[1]-p));
// }
double distSP(S a,P p){
  if(dot(a[1]-a[0],p-a[0])<EPS) return abs(p-a[0]);
  if(dot(a[0]-a[1],p-a[1])<EPS) return abs(p-a[1]);
  return abs(cross(a[1]-a[0],p-a[0]))/abs(a[1]-a[0]);
}
double distSS(S a,S b){
  return isCrossSS(a,b)?0:
    min(
      min(distSP(a,b[0]),distSP(a,b[1])),
      min(distSP(b,a[0]),distSP(b,a[1]))
    );
}

//??????????????????
bool isCrossCP(C a,P p){
  return abs(a.p-p)-a.r<=EPS;
}
bool isCrossCL(C a,L l){
  return distLP(l,a.p)-a.r<EPS;
}
double distSP_MAX(S a,P p){
  return max(abs(a[0]-p),abs(a[1]-p));
}
bool isCrossCS(C a,S s){
  return distSP(s,a.p)-a.r<EPS;
}
bool isCrossCC(C a,C b){//??\?????????????????????
  return abs(a.p-b.p)-(a.r+b.r) <= EPS;
}



void mainmain(){
	int N;
	double R;
	while(cin>>R>>N,N){
		typedef pair<C,double> ufo;
		vector<ufo> v(N);
		rep(i,N){
			double a,b;
			cin>>a>>b;
			v[i].fi.p=P(a,b);
			cin>>a>>b;
			v[i].fi.r=a;
			v[i].se=b;
		}
		vector<ufo> w=v;
		int cnt=0;
		int loop=1;
		bool f=false;
		while(v.size()){
			int x1=-1;
			double x2=1e10;
			if(f) rep(i,v.size()){
				if(R-abs(v[i].fi.p)>-EPS) continue;
				if(x2>abs(v[i].fi.p)){
					x1=i;
					x2=abs(v[i].fi.p);
				}
			}
			// cout<<x1<<" "<<x2<<endl;
			if(f) if(x1==-1){
				break;
			}
			if(f) if(x1!=-1){
				P t1(v[x1].fi.p.X*1e6,v[x1].fi.p.Y*1e6);
				P t2(v[x1].fi.p.X*R/abs(v[x1].fi.p),v[x1].fi.p.Y*R/abs(v[x1].fi.p));
				S tmp(t2,t1);
				rep(i,v.size()){
					if(R-abs(v[i].fi.p)>-EPS) continue;
					if(isCrossCS(v[i].fi,tmp)){
						cnt++;
						v.erase(v.begin()+i);
						w.erase(w.begin()+i);
						i--;
					}
				}
			}
			rep(i,v.size()){
				if(v[i].se-abs(v[i].fi.p)>-EPS){
					v.erase(v.begin()+i);
					w.erase(w.begin()+i);
					i--;
				}
			}
			rep(i,v.size()){
				P tmp(-w[i].fi.p.X*w[i].se*loop/abs(w[i].fi.p),-w[i].fi.p.Y*w[i].se*loop/abs(w[i].fi.p));
				v[i].fi.p=w[i].fi.p+tmp;
				// cout<<v[i].fi.p.X<<" "<<v[i].fi.p.Y<<" "<<v[i].fi.r<<" "<<v[i].se<<endl;
			}
			loop++;
			f=true;
		}
		cout<<N-cnt<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1272