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<iostream>
#include<cstdio>
#define _USE_MATH_DEFINES
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;


#define INF 1e+10
#define EPS 1e-10
#define EQ(a,b) (abs(a-b)<EPS)

//ティツェツ、テ・ツキツョテ」ツつ津ィツ?εヲツ?ョテ」ツ?療」ツ?ヲティツカツウテ」ツ?療ァツョツ?
double add(double a,double b){
	if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
	return a+b;
}
struct P{//2テヲツャツ。テ・ツ?ε」ツδ凖」ツつッテ」ツδ暗」ツδォ
	double x,y;
	P(){}
	P(double x,double y):x(x),y(y){}
	P operator + (P p){
		return P(add(x,p.x),add(y,p.y));
	}
	P operator - (P p){
		return P(add(x,-p.x),add(y,-p.y));
	}
	P operator * (double d){
		return P(x*d,y*d);
	}
	P operator / (double d){
		return P(x/d,y/d);
	}
	double dot(P p){//テ・ツ??ァツゥツ?
		return add(x*p.x,y*p.y);
	}
	double det(P p){//テ・ツ、ツ姪ァツゥツ?
		return add(x*p.y,-y*p.x);
	}
	bool equal(P p){
		return (x-p.x)*(x-p.x)+(y-p.y)*(y-p.y) < EPS*EPS;
	}
};
//typedef pair<P,P> Line;

//テァツキツ堙・ツ按?1-p2テ、ツクツ甘」ツ?ォテァツつケqテ」ツ?古」ツ?づ」ツつ凝」ツ?凝・ツ按、テ・ツョツ?
bool on_seg(P p1,P p2,P q){
	return (p1-q).det(p2-q)==0 && (p1-q).dot(p2-q)<=0;
}
//テァツ崢エテァツキツ嗔1-p2テ」ツ?ィテァツ崢エテァツキツ嘔1-q2テ」ツ?ョテ、ツコツ、テァツつケ
P intersection(P p1,P p2,P q1,P q2){
	return p1+(p2-p1)*( (q2-q1).det(q1-p1)/(q2-q1).det(p2-p1) );
}


//テァツキツ堙・ツ按?1-p2テ」ツ?ィテァツキツ堙・ツ按?1-q2テ」ツ?古、ツコツ、テ・ツキツョテ」ツ?凖」ツつ凝」ツ??
bool exist_intersection(P p1,P p2,P q1,P q2){
	if(on_seg(p1,p2,q1)||on_seg(p1,p2,q2)||on_seg(q1,q2,p1)||on_seg(q1,q2,p2))return true;
	if((p1-p2).det(q1-q2)==0 )return false;//テ・ツケツウティツ。ツ?
	P a=intersection(p1,p2,q1,q2);
	return on_seg(p1,p2,a) && on_seg(q1,q2,a);
}
//テ・ツ篠淌ァツつケテ、ツクツュテ・ツソツε・ツ崢榲ィツサツ「
P rotate(P p,double rad){
	double s=sin(rad),c=cos(rad);
	return P(c*p.x-s*p.y, s*p.x+c*p.y);
}
//originテ」ツつ津、ツクツュテ・ツソツε」ツ?ォテ・ツ崢榲ィツサツ「
P rotate(P p,double rad,P origin){
	return origin + rotate(p - origin,rad);
}
//テ、ツコツ古ァツつケテゥツ鳴禿」ツ?ョティツキツ敕ゥツ崢「
double dist(P p,P q){
	p = p-q;
	return sqrt(p.x*p.x+p.y*p.y);
}
//テ・ツ債佚、ツスツ催」ツδ凖」ツつッテ」ツδ暗」ツδォテ」ツ?ォテ・ツ、ツ嘉ヲツ渉?
P to_unit(P p){
	double d = sqrt(p.x*p.x+p.y*p.y);
	return p/d;
}
//テ・ツ??・ツ青古・ツ」ツォテ」ツ?ョテ、ツコツ、テァツつケテ」ツつ津ィツィツ暗ァツョツ?
pair<P,P> circle_intersection(double x1,double y1,double r1,double x2,double y2,double r2){
	double rad = atan2(y2-y1,x2-x1);
	x2 -= x1;
	y2 -= y1;
	P tmp = rotate(P(x2,y2),-rad);
	x2 = tmp.x;
	y2 = tmp.y;
	double x = (r1*r1-r2*r2+x2*x2)/(2*x2);
	if(abs(r1) < abs(x))return make_pair(P(0,0),P(0,0));//テ、ツコツ、テァツつケテ」ツ?ェテ」ツ??
	double y = sqrt(r1*r1-x*x);
	return make_pair( P(x1,y1)+rotate(P(x,y),rad) ,  P(x1,y1)+rotate(P(x,-y),rad) );
}
//2テァツつケテ」ツつ津ゥツ?堙」ツつ凝・ツ債甘・ツセツвテ」ツ?ョテ・ツ??」ツ?ョテ、ツクツュテ・ツソツε・ツコツァテヲツィツ?
vector<P> circle_on_2P(P p,P q,double r){
	vector<P> res; 
	if(2*r+EPS < dist(p,q))return res;//ティツァツ」テ」ツ?ェテ」ツ??
	if(q.x < p.x)swap(p,q);
	q = q - p;
	double rad = atan2(q.y,q.x);
	P tmp = rotate(q,-rad);
	double x = tmp.x/2;
	double y = sqrt(4*r*r-tmp.x*tmp.x)/2;
	P a = p+rotate(P(x,y),rad) , b = p+rotate(P(x,-y),rad);
	res.push_back(a);
	if(!a.equal(b))res.push_back(b);
	return res;
}
//テァツキツ堙・ツ按?」ツ?ィテァツつケテ」ツ?ョティツキツ敕ゥツ崢「
double dist_LP(P p1,P p2,P q){
	double dx,dy;
	dx = p1.x-p2.x;
	dy = p1.y-p2.y;
	double d = min(dist(p1,q) ,dist(p2,q));
	pair<P,P> normal = make_pair(q+to_unit(P(-dy,dx))*d ,q+to_unit(P(dy,-dx))*d);//テヲツウツ陛ァツキツ堙」ツδ凖」ツつッテ」ツδ暗」ツδォ
	if(exist_intersection(p1,p2,normal.first,normal.second)){
		return dist(q, intersection(p1,p2,normal.first,normal.second));
	}
	return d;
}
//テァツキツ堙・ツ按?ゥツ鳴禿」ツ?ョティツキツ敕ゥツ崢「
double dist_LL(P p1,P p2,P q1,P q2){
	if(exist_intersection(p1,p2,q1,q2))return 0;
	return min( min(dist_LP(p1,p2,q1),dist_LP(p1,p2,q2))
		,min(dist_LP(q1,q2,p1),dist_LP(q1,q2,p2)) );
}
//テ」ツδゥテ」ツつクテ」ツつ「テ」ツδウテ」ツ?ォテ・ツ、ツ嘉ヲツ渉?
double radian(double angle){
	return angle/180.0*M_PI;
}



//テ・ツ、ツ堙ィツァツ津・ツスツ「テ・ツ??ゥツδィテ」ツ?ォテァツつケpテ」ツ?古」ツ?づ」ツつ凝」ツ??
bool contains(const vector<P> &poly,P p,double inf=INF){
	int cnt=0;
	P q(p.x+inf,p.y);
	for(int i=0;i<poly.size();i++){
		if(exist_intersection(poly[i],poly[(i+1)%poly.size()],p,q))cnt++;
	}
	return cnt&1;
}
//テァツつケpテ」ツつ津ゥツ?堙」ツつ凝・ツ??」ツ?ョテヲツ篠・テァツキツ?
pair<P,P> tangent_CP(double x,double y,double r,P p){
	//P q(x,y), m((x+p.x)/2,(y+p.y)/2);
	double d=sqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y))/2;
	return circle_intersection(x,y,r,(x+p.x)/2,(y+p.y)/2,d);
}




struct UFO{
	double x,y,r,v;
	bool move(int R){
		double d=sqrt(x*x+y*y);
		if(d-v<R+EPS)return true;
		double rad=atan2(-y,-x);
		x+=cos(rad)*v;
		y+=sin(rad)*v;
		return false;
	}
	double dist2(){
		return x*x+y*y;
	}
	double radian(){
		return atan2(y,x);
	}
};
int main(){
	int n;
	int R;
	while(cin>>R>>n,R|n){
		vector<UFO> ufo;
		for(int i=0;i<n;i++){
			UFO u;
			cin>>u.x>>u.y>>u.r>>u.v;
			ufo.push_back(u);
		}
		int ans=0;
		while(!ufo.empty()){
			for(int i=0;i<ufo.size();i++)
				if(ufo[i].move(R)){
					ufo.erase(ufo.begin()+i);
					ans++;
				}
			if(ufo.empty())break;
			int mini=0;
			for(int i=ufo.size()-1;i>=0;i--){
				if(ufo[i].dist2() < ufo[mini].dist2())mini=i;
			}
			double rad=ufo[mini].radian();
			P p(0.0,0.0),q=P(cos(rad),sin(rad))*2000;
			for(int i=ufo.size()-1;i>=0;i--){
				double d=dist_LP(p,q,P(ufo[i].x,ufo[i].y));
				if(d < ufo[i].r+EPS){
					ufo.erase(ufo.begin()+i);
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}