// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>

struct P {
    float x, y;
    P operator-(const P& p) {
        return P{x - p.x, y - p.y};
    }
};

float dot(const P& p1, const P& p2) {
    return p1.x * p2.x + p1.y * p2.y;
}

float cross(const P& p1, const P& p2) {
    return p1.x * p2.y - p1.y * p2.x;
}

float abs(const P& p) {
    return std::sqrt(p.x * p.x + p.y * p.y);
}

float distance_ls_p(P a, P b, P c) {
  if ( dot(c-b, a-b) < 1e-6 ) return abs(b-a);
  if ( dot(a-c, b-c) < 1e-6 ) return abs(c-a);
  return std::abs(cross(b-c, a-b)) / abs(b-c);
}

int main()
{
    struct UFO {
        float x, y;
        float v;
        float r;
        float sita;
        float d;
    };
    
    while (true) {
        int count = 0;
        int R, N;
        std::cin >> R >> N;
        
        if (R == 0 && N == 0) {
            break;
        }
        
        std::vector<UFO> ufos(N);
        
        for (int i = 0; i < N; i++) {
            std::cin >> ufos[i].x >> ufos[i].y >> ufos[i].r >> ufos[i].v;
            ufos[i].sita = std::atan2(ufos[i].y, ufos[i].x);
            ufos[i].d = std::sqrt(ufos[i].x * ufos[i].x + ufos[i].y * ufos[i].y);
        }
        
        while (!ufos.empty()) {
            for (std::size_t i = 0; i < ufos.size(); i++) {
                ufos[i].d = std::max(ufos[i].d - ufos[i].v, 0.0f);
                ufos[i].x = std::cos(ufos[i].sita) * ufos[i].d;
                ufos[i].y = std::sin(ufos[i].sita) * ufos[i].d;
            }
            
            count += std::count_if(ufos.begin(), ufos.end(), [R](auto& elem){
                return elem.d <= R;
            });
            
            {
                auto rm_it = std::remove_if(ufos.begin(), ufos.end(), [R](auto& elem){
                    return elem.d <= R;
                });
                ufos.erase(rm_it, ufos.end());
            }
            
            std::sort(ufos.begin(), ufos.end(), [](auto& lhs, auto& rhs){
                return lhs.d < rhs.d;
            });
            
            if (ufos.empty()) {
                break;
            }
            
            float a = ufos[0].y / ufos[0].x;
            {
                float shot_angle = std::atan2(ufos[0].y, ufos[0].x);
                auto rm_it = std::remove_if(ufos.begin(), ufos.end(), [shot_angle, R, a, &ufos](auto& elem){
                    return distance_ls_p(P{elem.x, elem.y}, 
                                         P{R * std::cos(shot_angle), R * std::sin(shot_angle)},
                                         P{1e6f * std::cos(shot_angle), 1e6f * std::sin(shot_angle)}) < elem.r;
                });
                ufos.erase(rm_it, ufos.end());
            }
        }
        printf("%d\n", count);
    }
}

