from math import sqrt

class Ufo:
	def __init__(self,px,py,d,vd,ui):
		self.pd=sqrt(px**2+py**2)
		self.px=float(px)
		self.py=float(py)
		self.ex=self.px/self.pd
		self.ey=self.py/self.pd
		self.d=float(d)
		self.vd=float(vd)
		self.vx=-self.vd*self.ex
		self.vy=-self.vd*self.ey
		self.i=ui
	def move(self):
		self.pd -= self.vd
		self.px += self.vx
		self.py += self.vy



while True:
	R,ul=tuple(map(int,raw_input().split()))
	if(R==0 and ul==0): break
	us=[]
	for ui in xrange(ul):
		px,py,d,vd = tuple(map(int,raw_input().split()))
		u = Ufo(px,py,d,vd,ui)
		us.append(u)

	re=0
	while len(us)!=0:
		for u in us: u.move()
		us.sort(key=lambda u: u.pd)

		for u in us[:]:
			if u.pd<=R:
				re+=1
				us.remove(u)
				#print u.i, "due to invade"
				continue
			else:
				break

		neu=us.pop(0)
		#print "focus",neu.i
		#print neu.i,"due to hit"
		laserex=neu.ex
		laserey=neu.ey

		for u in us[:]:
			d = u.pd*abs(laserex*u.ey-laserey*u.ex)	#u kara laser ni orosita suisen no nagasa
			if d<u.d:
				if u.pd*abs(laserex*u.ex+laserey*u.ey)+sqrt(u.d**2-d**2) > R:
					us.remove(u)
					#print u.i, "due to hit"

	print re