Go: package main

import (
	"bufio"
	"os"
	"math"
	"strings"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

const (
	INF = 0x7FFFFFFF
	EPS = 1e-10
)

type Point struct {
	x, y float64
}
func (p *Point) plus(q *Point) *Point {
	return &Point{p.x + q.x, p.y + q.y}
}
func (p *Point) minus(q *Point) *Point {
	return &Point{p.x - q.x, p.y - q.y}
}
func (p *Point) multi(a float64) *Point {
	return &Point{p.x * a, p.y * a}
}
func (p *Point) div(a float64) *Point {
	return &Point{p.x / a, p.y / a}
}
func (p *Point) abs() float64 {
	return math.Sqrt(p.norm())
}
func (p *Point) norm() float64 {
	return p.x*p.x + p.y*p.y
}
func (p *Point) isLessThan(q *Point) bool {
	if p.x != q.x {
		return p.x < q.x && p.y < q.y
	}
	return true
}
func (p *Point) isEqual(q *Point) bool {
	return math.Abs(p.x - q.x) < EPS && math.Abs(p.y - q.y) < EPS
}

type Segment struct {
	p1, p2 *Point
}
func (s *Segment) norm() float64 {
	return (s.p2.x - s.p1.x)*(s.p2.x - s.p1.x) +
		(s.p2.y - s.p1.y)*(s.p2.y - s.p1.y)
}
func (s *Segment) abs() float64 {
	return math.Sqrt(s.norm())
}

func norm(a *Point) float64 {
	return a.x*a.x + a.y*a.y
}

func abs(a *Point) float64 {
	return math.Sqrt(norm(a))
}

func polar(a, r float64) *Point {
	return &Point{math.Cos(r)*a, math.Sin(r)*a}
}

func getDistance(a, b *Point) float64 {
	return abs(a.minus(b))
}

func dot(a, b *Point) float64 {
	return a.x*b.x + a.y*b.y
}

func cross(a, b *Point) float64 {
	return a.x*b.y - a.y*b.x
}

func getDistanceLP(s Segment, p *Point) float64 {
	return cross(s.p2.minus(s.p1), p.minus(s.p1))/ abs(s.p2.minus(s.p1))
}

func getDistanceSP(s Segment, p *Point) float64 {
	if dot(s.p2.minus(s.p1), p.minus(s.p1)) < 0 {
		return abs(p.minus(s.p1))
	}
	if dot(s.p1.minus(s.p2), p.minus(s.p2)) < 0 {
		return abs(p.minus(s.p2))
	}
	return getDistanceLP(s, p)
}

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		R, _ := strconv.Atoi(buf[0])
		N, _ := strconv.Atoi(buf[1])
		if R == 0 && N == 0 {
			break
		}
		p := make([]*Point, N)
		r := make([]float64, N)
		v := make([]float64, N)
		d := make([]float64, N)
		nd := make([]float64, N)
		die := make([]bool, N)
		for i := 0; i < N; i++ {
			scanner.Scan()
			buf_ := strings.Split(scanner.Text(), " ")
			_x, _ := strconv.ParseFloat(buf_[0], 64)
			_y, _ := strconv.ParseFloat(buf_[1], 64)
			_r, _ := strconv.ParseFloat(buf_[2], 64)
			_v, _ := strconv.ParseFloat(buf_[3], 64)
			tmp := &Point{_x, _y}
			p[i] = tmp
			r[i] = _r
			v[i] = _v
			nd[i] = getDistance(p[i], &Point{0, 0})
			d[i] = getDistance(p[i], &Point{0, 0})
			die[i] = false
		}
		for {
			for i := 0; i < N; i++ {
				nd[i] = math.Max(float64(R), nd[i]-v[i])
			}
			mini := float64(INF)
			id := -1
			for i := 0; i < N; i++ {
				if die[i] {
					continue
				}
				if nd[i] < EPS+float64(R) {
					continue
				}
				if nd[i] > mini {
					continue
				}
				mini = nd[i]
				id = i
			}
			if id == -1 {
				break
			}
			s := Segment{p[id], p[id]}
			s.p1 = s.p1.div(d[id])
			s.p1 = s.p1.multi(float64(R))
			s.p2 = s.p2.div(d[id])
			s.p2 = s.p2.multi(10000000.0)
			for i := 0; i < N; i++ {
				if nd[i] < EPS + float64(R) {
					continue
				}
				a := p[i]
				a = a.div(d[i])
				a = a.multi(nd[i])
				if getDistanceSP(s, a) < EPS + r[i] {
					die[i] = true
				}
			}
		}
		ans := 0
		for i := 0; i < N; i++ {
			if !die[i] {
				ans++
			}
		}
		fmt.Println(ans)
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define REP(i, s, e) for ( int i = s; i <= e; i++ )  

const double INF = 1e12;
typedef complex<double> P,point;
typedef vector<P> G,polygon;
namespace std {bool operator < (const P& a, const P& b) {return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);}}
double cross(const P& a, const P& b) {return imag(conj(a)*b);}
double dot(const P& a, const P& b) {return real(conj(a)*b);}
struct L : public vector<P> {L(const P &a, const P &b) {push_back(a); push_back(b);}};
struct C {P p; double r;C(const P &p, double r) : p(p), r(r) { } C(){}};
int ccw(P a, P b, P c) {b -= a; c -= a;if (cross(b, c) > 0)   return +1;if (cross(b, c) < 0)   return -1;if (dot(b, c) < 0) return +2;if (norm(b) < norm(c)) return -2;return 0;}

// Check Funcs //
bool intersectLL(const L &l, const L &m) {return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;}
bool intersectLS(const L &l, const L &s) {return cross(l[1]-l[0], s[0]-l[0])*cross(l[1]-l[0], s[1]-l[0]) < EPS;}
bool intersectLP(const L &l, const P &p) {return abs(cross(l[1]-p, l[0]-p)) < EPS;}
bool intersectSS(const L &s, const L &t) {return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 && ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;}
bool intersectSP(const L &s, const P &p) {return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS;}

// Where is Point in Polygon? //
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
enum { OUT, ON, IN };
int contains(const polygon& P, const point& p) {bool in = false;for (int i = 0; i < P.size(); ++i) {point a = curr(P,i) - p, b = next(P,i) - p;if (imag(a) > imag(b)) swap(a, b);if (imag(a) <= 0 && 0 < imag(b))if (cross(a, b) < 0) in = !in;if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;}return in ? IN : OUT;}
// Area of Polygon //
double area2(const polygon& P) {double A = 0;for (int i = 0; i < P.size(); ++i)A += cross(curr(P, i), next(P, i));return A;}
// Totsuhou! Andrew's Monotone Chain //
vector<point> convex_hull(vector<point> ps) {int n = ps.size(), k = 0;sort(ps.begin(), ps.end());vector<point> ch(2*n);for (int i = 0; i < n; ch[k++] = ps[i++])while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--])while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;ch.resize(k-1);return ch;}

P projection(const L &l, const P &p) {double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);return l[0] + t*(l[0]-l[1]);}
P reflection(const L &l, const P &p) {return p + 2.0 * (projection(l, p) - p);}
double distanceLP(const L &l, const P &p) {return abs(p - projection(l, p));}
double distanceLL(const L &l, const L &m) {return intersectLL(l, m) ? 0 : distanceLP(l, m[0]);}
double distanceLS(const L &l, const L &s) {if (intersectLS(l, s)) return 0;return min(distanceLP(l, s[0]), distanceLP(l, s[1]));}
double distanceSP(const L &s, const P &p) {const P r = projection(s, p);if (intersectSP(s, r)) return abs(r - p);return min(abs(s[0] - p), abs(s[1] - p));}
double distanceSS(const L &s, const L &t) {if (intersectSS(s, t)) return 0;  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),min(distanceSP(t, s[0]), distanceSP(t, s[1])));}
P crosspoint(const L &l, const L &m) {double A = cross(l[1] - l[0], m[1] - m[0]);double B = cross(l[1] - l[0], l[1] - m[0]);if (abs(A) < EPS && abs(B) < EPS) return m[0];return m[0] + B / A * (m[1] - m[0]);}

vector<P> C_cp(C a,C b){
	vector<P> ret;
	double L = abs(a.p-b.p);
	
	/* anma dekitenai */
	if(	L-a.r-b.r > EPS || (abs(a.p-b.p)<EPS && fabs(a.r-b.r)<EPS) || 
		abs(a.p-b.p) < abs(a.r-b.r)
	)return ret;
	
	double theta = atan2(b.p.imag()-a.p.imag(),b.p.real()-a.p.real());
	double c = (L*L+a.r*a.r-b.r*b.r)/(2*L*a.r);
	ret.push_back(
		P(a.p.real()+a.r*cos(theta+acos(c)),
		  a.p.imag()+a.r*sin(theta+acos(c)))
	);
	if(fabs(L-a.r-b.r) > EPS)
		ret.push_back(
			P(a.p.real()+a.r*cos(theta-acos(c)),
			  a.p.imag()+a.r*sin(theta-acos(c)))
		);
	return ret;
}


//y-y1-ax+ax1=0;
//
P getPedal(L l, P p){
	double A;
	if(abs(l[1].real()-l[0].real()) < EPS){
		return P(l[1].real(),p.imag()); // important
	}else{
		A = (l[1].imag()-l[0].imag())/(l[1].real()-l[0].real());
	}
	double a = -A , b = 1 , c = A*l[0].real() - l[0].imag();
	double t = (a*p.real() + b*p.imag() + c)/(a*a+b*b);
	return p-t * P(a,b);
}
vector<P> crosspointCL(const L l, const C c){
	vector<P> ret;
	P p = getPedal(l,c.p);
	if(	abs(p-c.p) > c.r+EPS)return ret;
	P e = P((l[1]-l[0])/abs(l[1]-l[0]));
	double S = sqrt(c.r*c.r-abs(p-c.p)*abs(p-c.p));
	ret.push_back(p+S*e);
	ret.push_back(p-S*e);
	return ret;
}

class UFO{
public:
	C c;
	double v;
	UFO(double a){c = C(P(0,0),-1);};
	UFO(){};
};

bool operator<(const UFO&a,const UFO&b){
	return abs(a.c.p) < abs(b.c.p); 
}
bool operator==(const UFO&a,const UFO&b){
	return a.c.r == b.c.r;
}	
int main(){
	int n;
	double x,y,r,v,R;
	while(cin >> R >> n, R){
		int ret = 0;
		vector<UFO> dt;
		rep(i,n){
			cin >> x >> y >> r >> v;
			UFO t; t.c = C(P(x,y),r);
			t.v = v;
			dt.push_back(t);
		}
		while(dt.size()){
			rep(i,dt.size()){
				double th = atan2(dt[i].c.p.imag(),dt[i].c.p.real());
				if(dt[i].v > abs(dt[i].c.p))dt[i].c.p = P(0,0);
				else dt[i].c.p = P(cos(th) * (abs(dt[i].c.p)-dt[i].v) , sin(th) * (abs(dt[i].c.p)-dt[i].v) );
			}
			rep(i,dt.size()){
				if(abs(dt[i].c.p) <= R + EPS){
					ret ++;
					dt[i] = UFO(-1);
				}
			}
			dt.erase(remove(all(dt),UFO(-1)),dt.end());
			sort(all(dt));
				
			/*rep(i,dt.size()){
				cout << dt[i].c.p.real() << "," << dt[i].c.p.imag() << " " << dt[i].c.r << "  |" << abs(dt[i].c.p) << endl;
			}cout << "[" << ret << "]" << endl;
			*/
			L target(P(0,0),dt[0].c.p);
			bool checkX = dt[0].c.p.real() < 0, checkY = dt[0].c.p.imag() < 0;
			
			rep(i,dt.size()){
				vector<P> t = crosspointCL(target,dt[i].c);
				rep(j,t.size()){
					//cout << dt[i].c.p << " " << t[0] << " " << t[1] << "[" << dt[i].c.r << "]" << endl;
					bool cxcx = t[j].real() < 0 , cycy = t[j].imag() < 0;
					if(cxcx == checkX && cycy == checkY){
						dt[i] = UFO(-1);
						break;
					}
				}
			}
			dt[0] = UFO(-1);
			dt.erase(remove(all(dt),UFO(-1)),dt.end());
		}
		cout << ret << endl;
	}
}