#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-5;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

typedef complex<double> Point;

struct Line{
	Point pos,dir;
	Line(){}
	Line(Point p,Point d):pos(p),dir(d){}
};

int Signum(double x)
{
	return abs(x)<EPS?0:x<0?-1:1;
}

double Dot(Point a,Point b)
{
	return real(conj(a)*b);
}

double Cross(Point a,Point b)
{
	return imag(conj(a)*b);
}

Point Proj(Line l,Point p)
{
	Point a=p-l.pos,b=l.dir;
	return Dot(a,b)/norm(b)*b+l.pos;
}

double DistLP(Line l,Point p)
{
	return abs(Proj(l,p)-p);
}

int main()
{
	for(int r,n;cin>>r>>n,r|n;){
		vector<Point> ps(n);
		vi rs(n),vs(n);
		rep(i,n) cin>>real(ps[i])>>imag(ps[i])>>rs[i]>>vs[i];
		
		vi in(n),down(n);
		rep(i,n)
			if(norm(ps[i])<r*r+EPS)
				in[i]=1;
		
		for(int t=1;;t++){
			rep(i,n) if(!in[i] && !down[i]){
				Point d=ps[i]/abs(ps[i]);
				Point p=ps[i]-1.*vs[i]*t*d;
				if(Signum(real(p))!=Signum(real(ps[i])) || abs(p)<r+EPS)
					in[i]=1;
			}
			
			int target=-1;
			rep(i,n) if(!in[i] && !down[i])
				if(target==-1 || abs(ps[i])<abs(ps[target])-EPS)
					target=i;
			if(target==-1)
				break;
			
			Line l(Point(0,0),ps[target]);
			rep(i,n) if(!in[i] && !down[i])
				if(DistLP(l,ps[i])<r+EPS)
					down[i]=1;
		}
		
		cout<<count(all(in),1)<<endl;
	}
	
	return 0;
}