#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <set>

#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(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

struct ufo{
	int x;
	int y;
	int r;
	int v;
	int dsq;
	void calcdist(int t){
		dsq = x*x+y*y - v*v*t*t;
		if(dsq < 0) dsq = 0;
	}
	const bool operator <(const ufo& other){
		return (dsq < other.dsq);
	}
};

int main(){

	while(1){
		int r, n;
		cin >> r >> n;
		if(!r&&!n) break;
		int rsq = r*r;

		vector<ufo> u(n);

		rep(i, n){
			cin >> u[i].x >> u[i].y >> u[i].r >> u[i].v;
		}

		int cnt = 0;
		int time = 0;
		while(!u.empty()){
			time++;
			rep(i, u.size()){
				u[i].calcdist(time);
			}
			sort(all(u));

			//cout << "time:" << time << endl;
			//rep(i, u.size()){
			//	cout << "d:" << u[i].dsq << endl;
			//}

			vector<ufo> rest;
			rep(i, u.size()){
				if(rsq >= u[i].dsq){
					cnt++;
					continue;
				}
				int lx = u[i].x;
				int ly = u[i].y;
				int ldsq = u[i].dsq;
				FOR(j, i, u.size()){
					int ux = u[j].x;
					int uy = u[j].y;
					int ur = u[j].r;
					int udsq = u[j].dsq;

					int dot = (lx*ux+ly*uy);

					if( dot < 0 || udsq - dot*dot/ldsq > ur){
						rest.push_back(u[j]);
					}
				}
				break;
			}
			u = rest;
		}
		cout << cnt << endl;
	}

	return 0;
}