include Math
def g;gets.split.map &:to_f;end
while(r,n=g)[0]>0
e=(1..n).map{x,y,*l=g;[(x*x+y*y)**0.5,atan(y/x)+(x<0?PI: 0),*l]}
(u=e.min_by{|d,_|d>r ?d:1e5}[1]
e.reject!{|d,t,s,v|i=s<d ?asin(s/d)+1e-10:7;d>r&&t-i<=u&&u<=t+i})while e.each{|l|l[0]-=l[3]}.any?{|d,_|d>r}
p e.size
end