#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-10;
typedef vector<double> vdouble;
typedef pair<double, double> pdouble;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(double i = x; i < n; i++)
template<class T> T RoundOff(T a){ return double(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

typedef complex<double> P;

struct Enemy 
{	
	P p;
	double r, v;
};

bool operator < (Enemy right, Enemy left)
{	return abs(right.p) < abs(left.p);	}

// OÏ
double cross(P a, P b)
{	return a.real() * b.imag() - b.real() * a.imag();	}

// àÏ
double dot(P a, P b)
{	return a.real() * b.real() + a.imag() * b.imag();	}

// _ÆüªÌ£
double dist(P a, P b, P c)
{
	if(dot(b - a, c - a) < EPS) return abs(c - a);
	if(dot(a - b, c - b) < EPS) return abs(c - b);
	
	return abs(cross(b - a, c - a)) / abs(b - a);
}


// ap ©ç av ÖÌüªª cp É é¼a r Ì~ÆÕË·é©Ç¤©
bool hit(P ap, P av, P cp, double r)
{
	return dist(ap, av, cp) < r + EPS;	
}

int main()
{
    int R, N;
    while(cin >> R >> N && (R || N))
    {
        vector<Enemy> enemy(N);
        
        rep(i, N) cin >> enemy[i].p.real() >> enemy[i].p.imag() >> enemy[i].r >> enemy[i].v;
		
        
        int res = 0;
        
		while(!enemy.empty())
        {
			// iR
			for(short i = enemy.size() - 1; 0 <= i; i--)
			{				
				// Ú®üªøÍ«EÆÕË·éÈçJEg
				if(abs(enemy[i].p) - enemy[i].v < R + EPS)
				{
					enemy.erase(enemy.begin() + i);
					res++;
				}
				
				enemy[i].p = polar(abs(enemy[i].p) - enemy[i].v, arg(enemy[i].p));
			}
			
			// WI
			P aim(polar(100000.0, arg((*min_element(ALL(enemy))).p)));
			P sf(polar(double(R + EPS), arg(aim)));
            			
            // UÎÛÉÆËAÆËüãÌGðê|
			for(short i = enemy.size() - 1; 0 <= i; i--)
            {
				// ÄµÄ¢­
				if(hit(sf, aim, enemy[i].p, enemy[i].r))
				{
					enemy.erase(enemy.begin() + i);
				}
			}
        }
        
        cout << res << endl;

    }
}