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<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;
typedef stringstream SS;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
SS ss;
#define debug ss
#endif

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n);i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[]={1,-1,0,0,1,-1,1,-1,0};
const int dy[]={0,0,1,-1,1,-1,-1,1,0};

int sig(double r){return r<-EPS?-1:r>EPS?1:0;}

struct P{
	double x,y;
	P(){}
	P(double x,double y):x(x),y(y){}
	P operator+(const P&a)const{return P(x+a.x,y+a.y);}
	P operator-(const P&a)const{return P(x-a.x,y-a.y);}
	P operator*(const P&a)const{return P(x*a.x-y*a.y,x*a.y+y*a.x);}
	P operator-()const{return P(-x,-y);}
	P operator*(const double&k)const{return P(x*k,y*k);}
	P operator/(const double&k)const{return P(x/k,y/k);}
	double abs2()const{return x*x+y*y;}
	double abs()const{return sqrt(abs2());}
	double arg()const{return atan2(y,x);}
	double dot(const P&a)const{return x*a.x+y*a.y;}
	double det(const P&a)const{return x*a.y-y*a.x;}
	P proj(const P&a)const{double k=dot(a)/abs2();return P(x*k,y*k);}
	bool operator<(const P&a)const{return x!=a.x?x<a.x:y<a.y;}
	bool operator==(const P&a)const{return sig(x-a.x)==0&&sig(y-a.y)==0;}
};

ostream &operator<<(ostream&os,const P&a){os<<"("<<a.x<<", "<<a.y<<")";return os;}
double tri(P a,P b,P c){return (b-a).det(c-a);}

struct L{
	P a,b;
	L(P a,P b):a(a),b(b){}
	P vec()const{return b-a;}
	P proj(const P&p)const{return a+vec().proj(p-a);}
	P refl(const P&p)const{return proj(p)*2-p;}
	int iSP(const P&p)const{
		int s=sig(vec().det(p-a));
		if(s!=0)return s;
		if(sig(vec().dot(p-a))<0)return -2;
		if(sig(vec().dot(p-b))<0)return 2;
		return 0;
	}
	int iLL(const L&l)const{
		if(sig(vec().det(l.vec())))return 1;
		if(sig(vec().det(l.a-a)))return 0;
		return -1;
	}
	bool iLS(const L&l)const{return sig(tri(a,b,l.a))*sig(tri(a,b,l.b))<=0;}
	bool iSS(const L&l)const{return iLS(l)&&l.iLS(*this);}
	P pLL(const L&l)const{return a+vec()*(l.a-a).det(l.vec())/b.det(l.vec());}
	double dLP(const P&p)const{return abs(tri(a,b,p))/vec().abs();}
	double dSP(const P&p)const{
		if(sig(vec().dot(p-a))<=0)return (p-a).abs();
		if(sig(vec().dot(p-b))>=0)return (p-b).abs();
		return dLP(p);
	}
	double dLL(const L&l)const{return iLL(l)?0:dLP(l.a);}
	double dLS(const L&l)const{return iLS(l)?0:min(dLP(l.a),dLP(l.b));}
	double dSS(const L&l)const{return iSS(l)?0:min(min(dSP(l.a),dSP(l.b)),min(l.dSP(a),l.dSP(b)));}
};



int main() {
	int R,n;
	P p[110];
	int r[110],v[110],state[110];
	IL{
		cin>>R>>n;
		if(R==0&&n==0)break;
		rep(i,n)cin>>p[i].x>>p[i].y>>r[i]>>v[i];
		memset(state,0,sizeof(state));
		IL{
			rep(i,n){
				if(state[i]!=0)continue;
				double a=v[i]/p[i].abs();
				if(a>1)a=1;
				p[i]=p[i]-p[i]*a;
			}
			rep(i,n){
				if(state[i]!=0)continue;
				if(p[i].abs()<=R+EPS)state[i]=-1;
			}
			int shoot=-1;
			rep(i,n){
				if(state[i]!=0)continue;
				if(shoot==-1||p[shoot].abs()>p[i].abs())shoot=i;
			}
			if(shoot==-1)break;
			L l(P(0,0),p[shoot]);
			rep(i,n){
				if(state[i]!=0)continue;
				if(l.iSP(p[i])==-2)continue;
				if(l.dLP(p[i])<=r[i]+EPS)state[i]=1;
			}
		}
		int res=0;
		rep(i,n)if(state[i]==-1)++res;
		cout<<res<<endl;
	}
	return 0;
}