#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
using namespace std;
typedef pair<int,int> P;
const int INF = 1<<29;
const double EPS = 1e-8;

struct ufo{
    int x,y,r,v;
    bool active;
};

double dist(ufo &a, int t){
    return sqrt(a.x*a.x+a.y*a.y) - a.v*t;
}

int main(){
    while(1){
        int R,N;
        scanf("%d %d",&R,&N);
        if(N==0)break;

        vector<ufo> enemys(N);
        for(int i=0;i<N;i++){
            int x,y,r,v;
            scanf("%d %d %d %d",&x,&y,&r,&v);
            enemys[i] = (ufo){x,y,r,v,true};
        }

        int count = 0, t = 1, ans = 0;
        while(count!=N){
            double min_d = 1500;
            int min_i = -1;
            for(int i=0;i<N;i++){
                if(!enemys[i].active) continue;
                double d = dist(enemys[i], t);
                if(d <= R+EPS){
                    enemys[i].active = false;
                    ans++;
                    count++;
                    continue;
                }
                if(min_d>d){
                    min_d = d;
                    min_i = i;
                }
            }
            if(count==N) break;
            ufo min_e = enemys[min_i];
            double abs_i = sqrt(min_e.x*min_e.x + min_e.y*min_e.y);
            for(int i=0;i<N;i++){
                if(!enemys[i].active) continue;
                double d = (min_e.x*enemys[i].y - min_e.y*enemys[i].x) / abs_i;
                if(d <= R+EPS){
                    enemys[i].active = false;
                    count++;
                }
            }
            t++;
        }
        cout << ans << endl;
    }

    return 0;
}