#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <vector>

// ???, ????????????
typedef std::complex<double> Point;
typedef Point Vector;

namespace std {
	bool operator < (const Point &a, const Point &b){
		return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
	}
	
	istream& operator >> (istream &is, Point &a){
		double x, y;
		is >> x >> y;
		a = Point(x, y);
		return is;
	}
	
	ostream& operator << (ostream &os, Point a){
		return os << a.real() << " " << a.imag();
	}
}

// ??´???
struct Line {
	Point p1, p2;
	Line(){}
	Line(const Point &p1, const Point &p2): p1(p1), p2(p2){}
};
typedef Line Segment;

namespace std {
	istream& operator >> (istream &is, Line &a){
		return is >> a.p1 >> a.p2;
	}
}

// ???
struct Circle {
	Point p; double r;
	Circle(){}
	Circle(const Point &p, double r): p(p), r(r){}
};

namespace std {
	istream& operator >> (istream &is, Circle &a){
		return is >> a.p >> a.r;
	}
}

// ????§???¢
typedef std::vector<Point> Polygon;

const double EPS = 1e-12;
const double INF = 1e12;
const double PI = acos(-1.0);

// ????????¨??????????????¢???
enum CCW {
	COUNTER_CLOCKWISE = 1,
	CLOCKWISE = -1,
	ONLINE_BACK = 2,
	ONLINE_FRONT = -2,
	ON_SEGMENT = 0,
};

// ?????¢????£????????????¢???
enum {
	OUT = 0,
	ON = 1,
	IN = 2,
};


// a ??? 2 ??? (a ^ 2)
double SQ(double a);

// ?????????????????????????????¢??°
bool EQ(double a, double b);
bool NEQ(double a, double b);
bool LT(double a, double b);
bool GT(double a, double b);
bool LEQ(double a, double b);
bool GEQ(double a, double b);

// ??§?????? <=> ?????°?????????
double toDeg(double t);
double toRad(double t);

// ????????? (dot(a, a))
double norm(const Vector &a);

// ??????, ??????
double dot(const Vector &a, const Vector &b);
double cross(const Vector &a, const Vector &b);

// ??´???, ??????
bool orthogonal(const Segment &s1, const Segment &s2);
bool parallel(const Segment &s1, const Segment &s2);

// ?°???±, ????°?
Point project(const Line &l, const Point &p);
Point reflect(const Line &l, const Point &p);

// ?????? (p0, p1) ??¨??? p2 ???????????¢???
int ccw(const Point &p0, const Point &p1, const Point &p2);

// ????????????
bool intersectLP(const Line &l, const Point &p);
bool intersectLL(const Line &l1, const Line &l2);
bool intersectLS(const Line &l, const Segment &s);
bool intersectSP(const Segment &s, const Point &p);
bool intersectSS(const Segment &s1, const Segment &s2);
int intersectCP(const Circle &c, const Point &p);
bool intersectCL(const Circle &c, const Line &l);
int intersectCS(const Circle &c, const Segment &s);
int intersectCC(const Circle &c1, const Circle &c2);

// ?????¢
double distanceLP(const Line &l, const Point &p);
double distanceLL(const Line &l1, const Line &l2);
double distanceLS(const Line &l, const Segment &s);
double distanceSP(const Segment &s, const Point &p);
double distanceSS(const Segment &s1, const Segment &s2);
double distanceCP(const Circle &c, const Point &p);
double distanceCL(const Circle &c, const Line &l);
double distanceCS(const Circle &c, const Segment &s);
double distanceCC(const Circle &c1, const Circle &c2);

// ??????
Point crossPointLL(const Line &l1, const Line &l2);
Point crossPointLS(const Line &l, const Segment &s);
Point crossPointSS(const Segment &s1, const Segment &s2);
std::vector<Point> crossPointCL(const Circle &c, const Line &l);
std::vector<Point> crossPointCS(const Circle &c, const Segment &s);
std::vector<Point> crossPointCC(const Circle &c1, const Circle &c2);


double SQ(double a){
	return a * a;
}

bool EQ(double a, double b){
	return std::abs(a - b) < EPS;
}

bool NEQ(double a, double b){
	return !EQ(a, b);
}

bool LT(double a, double b){
	return a - b < -EPS;
}

bool GT(double a, double b){
	return a - b > EPS;
}

bool LEQ(double a, double b){
	return !GT(a, b);
}

bool GEQ(double a, double b){
	return !LT(a, b);
}

double toDeg(double t){
	return t * 180 / PI;
}

double toRad(double t){
	return t / 180 * PI;
}

double norm(const Vector &a){
	return SQ(a.real()) + SQ(a.imag());
}

double dot(const Vector &a, const Vector &b){
	return (conj(a) * b).real();
}

double cross(const Vector &a, const Vector &b){
	return (conj(a) * b).imag();
}

// AOJ CGL_2_A
bool orthogonal(const Segment &s1, const Segment &s2){
	return EQ(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

// AOJ CGL_2_A
bool parallel(const Segment &s1, const Segment &s2){
	return EQ(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

// AOJ CGL_1_A
Point project(const Line &l, const Point &p){
	Vector base = l.p2 - l.p1;
	double r = dot(p - l.p1, base) / norm(base);
	return l.p1 + base * r;
}

// AOJ CGL_1_B
Point reflect(const Line &l, const Point &p){
	return p + (project(l, p) - p) * 2.0;
}

// AOJ CGL_1_C
int ccw(const Point &p0, const Point &p1, const Point &p2){
	Vector a = p1 - p0;
	Vector b = p2 - p0;
	if (GT(cross(a, b), 0.0)) return COUNTER_CLOCKWISE;
	if (LT(cross(a, b), 0.0)) return CLOCKWISE;
	if (LT(dot(a, b), 0.0)) return ONLINE_BACK;
	if (LT(norm(a), norm(b))) return ONLINE_FRONT;
	return ON_SEGMENT;
}

bool intersectLP(const Line &l, const Point &p){
	return LEQ(std::abs(cross(l.p1 - p, l.p2 - p)), 0.0);
}

bool intersectLL(const Line &l1, const Line &l2){
	return !parallel(l1, l2) || LEQ(std::abs(cross(l1.p2 - l1.p1, l2.p1 - l1.p1)), 0.0);
}

bool intersectLS(const Line &l, const Segment &s){
	return LEQ(cross(l.p2 - l.p1, s.p1 - l.p1) * cross(l.p2 - l.p1, s.p2 - l.p1), 0.0);
}

bool intersectSP(const Segment &s, const Point &p){
	return norm(s.p1 - p) + norm(s.p2 - p) - norm(s.p2 - s.p1) < EPS;
}

// CGL_2_B
bool intersectSS(const Segment &s1, const Segment &s2){
	return ccw(s1.p1, s1.p2, s2.p1) * ccw(s1.p1, s1.p2, s2.p2) <= 0 &&
		ccw(s2.p1, s2.p2, s1.p1) * ccw(s2.p1, s2.p2, s1.p2) <= 0;
}

int intersectCP(const Circle &c, const Point &p){
	double dd = norm(c.p - p);
	if (LT(dd, SQ(c.r))) return IN;
	if (EQ(dd, SQ(c.r))) return ON;
	return OUT;
}

bool intersectCL(const Circle &c, const Line &l){
	double d = distanceLP(l, c.p);
	return LEQ(d, c.r);
}

int intersectCS(const Circle &c, const Segment &s){
	double dd1 = norm(c.p - s.p1);
	double dd2 = norm(c.p - s.p2);
	if (LT(dd1, SQ(c.r)) && LT(dd2, SQ(c.r))) return IN;
	if (GT(dd1, SQ(c.r)) && GT(dd2, SQ(c.r))) return OUT;
	return ON;
}

// c1 ??? c2 ???????????????????????¨??? IN
// c1 ??? c2 ????????£???????????¨??? ON
// c1 ??? c2 ?????????????????¨??? OUT
int intersectCC(const Circle &c1, const Circle &c2){
	if (GT(norm(c1.p - c2.p), SQ(c1.r + c2.r))) return OUT;
	if (LT(norm(c1.p - c2.p), SQ(c2.r))) return IN;
	if (LT(norm(c1.p - c2.p), SQ(c1.r))) return OUT;
	return ON;
}

double distanceLP(const Line &l, const Point &p){
	return std::abs(cross(l.p2 - l.p1, p - l.p1)) / std::abs(l.p2 - l.p1);
}

double distanceLL(const Line &l1, const Line &l2){
	if (intersectLL(l1, l2)) return 0.0;
	return distanceLP(l1, l2.p1);
}

double distanceLS(const Line &l, const Segment &s){
	if (intersectLS(l, s)) return 0.0;
	return std::min(distanceLP(l, s.p1), distanceLP(l, s.p2));
}

double distanceSP(const Segment &s, const Point &p){
	if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return std::abs(p - s.p1);
	if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return std::abs(p - s.p2);
	return distanceLP(s, p);
}

// AOJ CGL_2_D
double distanceSS(const Segment &s1, const Segment &s2){
	if (intersectSS(s1, s2)) return 0.0;
	return std::min(
		std::min(
			distanceSP(s1, s2.p1),
			distanceSP(s1, s2.p2)
		),
		std::min(
			distanceSP(s2, s1.p1),
			distanceSP(s2, s1.p2)
		)
	);
}

double distanceCP(const Circle &c, const Point &p){
	return std::abs(std::abs(c.p - p) - c.r);
} 

double distanceCL(const Circle &c, const Line &l){
	if (intersectCL(c, l)) return 0.0;
	return distanceLP(l, c.p) - c.r;
}

double distanceCS(const Circle &c, const Segment &s){
	if (intersectCS(c, s)) return 0.0;
	return std::min(distanceCP(c, s.p1), distanceCP(c, s.p2));
}

double distanceCC(const Circle &c1, const Circle &c2){
	if (intersectCC(c1, c2) == ON) return 0.0;
	if (intersectCC(c1, c2) == IN){
		return c2.r - (std::abs(c1.p - c2.p) + c1.r);
	}
	if (intersectCC(c2, c1) == IN){
		return c1.r - (std::abs(c1.p - c2.p) + c2.r);
	}
	return (c1.r + c2.r) - (c1.r + c2.r);
}

Point crossPointLL(const Line &l1, const Line &l2){
	assert(intersectLL(l1, l2));
	Vector base = l2.p2 - l2.p1;
	double d1 = std::abs(cross(base, l1.p1 - l2.p1));
	double d2 = std::abs(cross(base, l1.p2 - l2.p1));
	double t = d1 / (d1 + d2);
	return l1.p1 + (l1.p2 - l1.p1) * t;
}

Point crossPointLS(const Line &l, const Segment &s){
	assert(intersectLS(l, s));
	return crossPointLL(l, s);
}

Point crossPointSS(const Segment &s1, const Segment &s2){
	assert(intersectSS(s1, s2));
	return crossPointSS(s1, s2);
}

std::vector<Point> crossPointCL(const Circle &c, const Line &l){
	if (!intersectCL(c, l)) return std::vector<Point>();
	std::vector<Point> ret;
	Vector proj = project(l, c.p);
	Vector e = (l.p2 - l.p1) / std::abs(l.p2 - l.p1);
	double base = sqrt(SQ(c.r) - norm(proj - c.p));
	ret.push_back(proj + e * base);
	ret.push_back(proj - e * base);
	return ret;
}

std::vector<Point> crossPointCS(const Circle &c, const Segment &s){
	std::vector<Point> ret = crossPointCL(c, s);
	for (int i = 0; i < ret.size(); i++){
		if (!intersectCP(c, ret[i])){
			swap(ret[i], ret.back());
			ret.pop_back();
			i--;
		}
	}
	return ret;
}

std::vector<Point> crossPointCC(const Circle &c1, const Circle &c2){
	if (!intersectCC(c1, c2)) return std::vector<Point>();
	std::vector<Point> ret;
	double d = std::abs(c1.p - c2.p);
	double a = std::acos((SQ(c1.r) + SQ(d) - SQ(c2.r)) / (2 * c1.r * d));
	double t = std::arg(c2.p - c1.p);
	ret.push_back(c1.p + std::polar(c1.r, t + a));
	ret.push_back(c1.p + std::polar(c1.r, t - a));
	return ret;
}


using namespace std;

struct UFO {
	Circle c;
	Vector v;
};

double R;
int N;
vector<UFO> ufo;

int solve()
{
	int res = 0;
	
	while (true){
		for (int i = 0; i < ufo.size(); i++){
			Point nx = ufo[i].c.p + ufo[i].v;
			if (LEQ(norm(nx), SQ(R)) || intersectSP(Segment(ufo[i].c.p, nx), Point(0, 0))){
				swap(ufo[i], ufo.back());
				ufo.pop_back();
				i--;
				res++;
				continue;
			}
			ufo[i].c.p = nx;
		}
		if (ufo.size() == 0) break;
		
		double mind = INF;
		int near = -1;
		for (int i = 0; i < ufo.size(); i++){
			if (norm(ufo[i].c.p) < mind){
				mind = norm(ufo[i].c.p);
				near = i;
			}
		}
		
		Segment s(Point(0, 0), ufo[near].c.p);
		for (int i = 0; i < ufo.size(); i++){
			if (intersectCS(ufo[i].c, s)){
				swap(ufo[i], ufo.back());
				ufo.pop_back();
				i--;
			}
		}
		
		if (ufo.size() == 0) break;
	}
	
	return res;
}

int main()
{
	std::cout << std::fixed << std::setprecision(12);
	
	while (cin >> R >> N, N){
		ufo.resize(N);
		for (int i = 0; i < N; i++){
			double v;
			cin >> ufo[i].c >> v;
			ufo[i].v = -ufo[i].c.p * v / abs(ufo[i].c.p);
		}
		
		cout << solve() << endl;
	}
}