#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

double dist(double a, double b){ return sqrt(a*a + b*b);
}

struct UFO{
    double x;
    double y;
    double r;
    double v;
    double cos;
    double sin;
    int disabled;
    int signx;
    int signy;
    UFO(){}
    ~UFO(){}
    UFO(int a, int b, int c, int d){
        x = a;
        y = b;
        r = c;
        v = d;
        disabled = 0;
        signx = x;
        signy = y;
        cos = x / dist(x, y);
        sin = y / dist(x, y);
    }
    UFO(const UFO& z){
        x = z.x; y = z.y; r = z.r; v = z.v;
        disabled = z.disabled;
        signx = z.signx;
        signy = z.signy;
        cos = z.cos;
        sin = z.sin;
    }
    bool operator<(const UFO& z) const {
        if( disabled - z.disabled ) return disabled < z.disabled;
        if( dist(x, y)-dist(z.x, z.y) ) return dist(x, y) < dist(z.x, z.y);
        return r < z.r;
    }
    void step(){
        double t1, t2;
        t1 = x - v * cos;
        t2 = y - v * sin;
        if( t1 * signx <= 0 ){ x = 0; }
        else{ x = t1; }
        if( t2 * signy <= 0 ){ y = 0; }
        else{ y = t2; }
    }
};

typedef vector<UFO> VU;

int main(){
    int N;
    double R;
    for(;cin >> R >> N, R||N;){
        VU u;
        for(int i = 0; i < N; i++){
            double a, b, c, d;
            cin >> a >> b >> c >> d;
            u.push_back( UFO(a, b, c, d) );
        }
        int ans = 0, count = 0;
        while(true){
            for(int i = 0; i < u.size(); i++){
                if( u[i].disabled ) continue;
                u[i].step();
                if( dist(u[i].x, u[i].y) <= R ){
                    u[i].disabled = 1;
                    ans++;
                }
            }
            sort(u.begin(), u.end());
            if( u[0].disabled ) break;
            double a = -u[0].y, b = u[0].x;
            for(VU::iterator it = u.begin(); it != u.end(); it++){
                if( it->disabled ) continue;
                if( dist(it->x-u[0].x, it->y-u[0].y) <= it->r ){
                    it->disabled = 1;
                }
                if( u[0].x*it->x+u[0].y*it->y >= 0 &&
                    abs(a*it->x+b*it->y)/dist(a, b) <= it->r ){
                    it->disabled = 1;
                }
            }
            sort(u.begin(), u.end());
        }
        cout << ans << endl;
    }
    return 0;
}