// 2012/08/08 Tazoe

#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

struct UFO{
	int x0;
	int y0;
	int r;
	int v;

	double d;
	double x;
	double y;
};

bool d_desc(const UFO& left, const UFO& right)
{
	return left.d > right.d;
}

int main()
{
	while(true){
		int R, N;
		cin >> R >> N;

		if(R==0&&N==0)
			break;

		struct UFO U[100];
		for(int i=0; i<N; i++){
			cin >> U[i].x0 >> U[i].y0 >> U[i].r >> U[i].v;
		}

		for(int i=0; i<N; i++){
			U[i].d = sqrt((double)(U[i].x0*U[i].x0+U[i].y0*U[i].y0));
			U[i].x = (double)U[i].x0;
			U[i].y = (double)U[i].y0;
		}

		int M = 0;

		while(N){
			sort(U, U+N, d_desc);
//			for(int i=0; i<N; i++){
//				cout << U[i].d << ' ' << U[i].x << ' ' << U[i].y << endl;
//			}

			for(int i=N-1; i>=0; i--){
				if(U[i].d<=(double)R){
					M++;
					N--;
				}
				else
					break;
			}

			double D = U[N-1].d;
			double X = U[N-1].x;
			double Y = U[N-1].y;

			N--;

			for(int i=N-1; i>=0; i--){
				double d = U[i].x*Y-U[i].y*X;
				if(d<0.0)
					d = -d;
				d /= D;
//				cout << d << ' ' << U[i].r << endl;

				if(d<=(double)U[i].r&&U[i].x*X>=0.0&&U[i].y*Y>=0.0){
					for(int j=i; j<N-1; j++){
						U[j] = U[j+1];
					}
					N--;
				}

			}

//			cout << M << ' ' << N << endl;

			for(int i=0; i<N; i++){
				double d_pre = U[i].d;
				U[i].d -= (double)U[i].v;
				if(U[i].d<0.0)
					U[i].d = 0.0;

				U[i].x = U[i].x*U[i].d/d_pre;
				U[i].y = U[i].y*U[i].d/d_pre;
			}
		}

		cout << M << endl;
	}

	return 0;
}