#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#define PI 3.141592
using namespace std;
class ufo {
public:
	float x;
	float y;
	float radius;
	float speed;
};

void move(vector<ufo> &);

int goal(vector<ufo>&,float);

void shot(vector<ufo>&, float, float);

int main() {
	float radius;
	int num;
	while (cin >> radius >> num&&num != 0) {
		vector<ufo> data(num);
		for (int i = 0; i < num; ++i) {
			cin >> data[i].x >> data[i].y >> data[i].radius >> data[i].speed;
		}
		int ans = 0;
		while (!data.empty()) {
			move(data);
			ans += goal(data, radius);
			if (data.empty())break;
			float fast;
			int place;
			fast = pow(data[0].x, 2.0) + pow(data[0].y, 2.0);
			place = 0;
			for (int i = 1; i < data.size(); ++i) {
				float di = pow(data[i].x, 2.0) + pow(data[i].y, 2.0);
				if (fast > di) {
					fast = di;
					place = i;
				}
			}
			shot(data, data[place].x, data[place].y);
		}
		cout << ans << endl;
	}
	return 0;
}

void shot(vector<ufo>& data, float x, float y) {
	float num = atan2(y, x);
	if (num < 0)num = PI * 2 + num;
	for (int i = 0; i < data.size(); ++i) {
		if (pow(data[i].x, 2.0) + pow(data[i].y, 2.0) <= data[i].radius) {
			swap(data[i], data.back());
			data.pop_back();
			--i;
		}
		else {
			float distance = sqrt(pow(data[i].x, 2.0) + pow(data[i].y, 2.0));
			float d = asin(data[i].radius / distance);
			float a = atan2(data[i].y, data[i].x);
			if (a < 0)a = PI * 2 + a;
			float b = a + d;
			float c = a - d;
			if (b < 0)b = PI * 2 + b;
			if (c < 0)c = PI * 2 + c;
			if ((b > num&&num > c) || (b<c&&PI*2+b>num&&num>c)||(b<c&&b>num&&num>c-PI*2)) {
				swap(data[i], data.back());
				data.pop_back();
				--i;
			}
		}
	}
}

int goal(vector<ufo>&data,float radius) {
	int res = 0;
	for (int i = 0; i < data.size(); ++i) {
		float x = data[i].x;
		float y = data[i].y;
		if (pow(x, 2.0) + pow(y, 2.0) <= pow(radius, 2.0)) {
			swap(data[i], data.back());
			data.pop_back();
			--i;
			++res;
		}
	}
	return res;
}

void move(vector<ufo>&data) {
	for (int i = 0, nmax = data.size(); i < nmax; ++i) {
		float x = -data[i].x;
		float y = -data[i].y;
		float per = sqrt(pow(x, 2.0) + pow(y, 2.0));
		if (per <= data[i].speed) {
			data[i].x = data[i].y = 0;
			continue;
		}
		x /= per;
		y /= per;
		x *= data[i].speed;
		y *= data[i].speed;
		data[i].x += x;
		data[i].y += y;
	}
}