import std.stdio, std.math;

struct UFO{
	int x, y, r, v;
  double d;
  bool isDie;
}

void main(){

	int laserR = 0, ufoNum = 0, times = -1;
  
  int ans[];
  
  UFO[] ufo;

  while(true){
  
		readf("%d %d\n", &laserR, &ufoNum);
		if(laserR == 0 && ufoNum == 0)	break;

    times++;
    ans.length = times + 1;
    ans[times] = 0;
    
    ufo.length = ufoNum;

    //UFOデータ読み込み
    {
    	int nx, ny, nr, nv;
    	for(int i=0; i<ufoNum; i++){
				readf("%d %d %d %d\n", &nx, &ny, &nr, &nv);
      	with(ufo[i]){
					x = nx;
        	y = ny;
        	r = nr;
        	v = nv;
          isDie = false;
        	d = sqrt(cast(double)(x*x + y*y));
      	}
    	}
    }

    while(true){

      //UFO進む
      for(int i=0; i<ufoNum; i++){
        if(ufo[i].isDie)	continue;
				ufo[i].d -= cast(double)ufo[i].v;
        if(ufo[i].d <= cast(double)laserR){
					ufo[i].isDie = true;
          ans[times]++;
        }
      }

      //一番近くて撃ち落せるUFO(min==-1のとき終了)
      int min = -1;
      {
      	double temp;
      	for(int i=0; i<ufoNum; i++){
					if(ufo[i].isDie)	continue;
          
        	if(min == -1){
						min = i;
        	  temp = ufo[i].d;
        	}else if(temp > ufo[i].d){
        	  min = i;
        	  temp = ufo[i].d;
        	}
      	}
      }

      //終了
      if(min == -1)	break;

      //撃ち落す
      ufo[min].isDie = true;
        for(int i=0; i<ufoNum; i++){
					if(ufo[i].isDie)	continue;
          
          with(ufo[i]){
						double nd = ufo[min].x * y - ufo[min].y * x;
            nd /= sqrt(cast(double)(ufo[min].x * ufo[min].x + ufo[min].y * ufo[min].y));
            
            if(nd > -r && nd < r){

              //半直線がy軸に近い
              if(ufo[min].x != 0 &&( cast(double)ufo[min].y / cast(double)ufo[min].x > 1 || cast(double)ufo[min].y / cast(double)ufo[min].x < -1)){
                if(y * ufo[min].y > 0){
                  isDie = true;
                }
              }else{	//半直線がx軸に近い
                if(x * ufo[min].x > 0){
									isDie = true;
                }
              }
            }

          }
          
        }

      
    }
    
  }

  for(int i=0; i<ans.length; i++){
		writeln(ans[i]);
  }

  
}