#include<cstdio>const double eps = 1e-8;double x0, y0, c, T;int n;double x, y, vx, vy;double A, B, C;double F(double t){ return A*t*t+B*t+C;}bool ok_min(double L, double R){ double low=L, top=R, m1, m2; double s1, s2, s3; while(top-low>eps){ m1 = low+(top-low)/3.0; m2 = top-(top-low)/3.0; s1 = F(m1); s2 = F(m2); if(s1<s2) top = m2-eps; else low = m1+eps; } s1 = F(L); s2 = F(R); s3 = F(low); if(s1*s3<eps || s2*s3<eps || s1*s2<eps) return 1; else return 0;}bool ok_max(double L, double R){ double low=L, top=R, m1, m2; double s1, s2, s3; while(top-low>eps){ m1 = low+(top-low)/3.0; m2 = top-(top-low)/3.0; s1 = F(m1); s2 = F(m2); if(s1<s2) low = m1+eps; else top = m2-eps; } s1 = F(L); s2 = F(R); s3 = F(low); if(s1*s3<eps || s2*s3<eps || s1*s2<eps) return 1; else return 0;}int check(){ A = vx*vx+vy*vy-c*c; B = 2.0*((x-x0)*vx+(y-y0)*vy); C = (x-x0)*(x-x0)+(y-y0)*(y-y0); if(A<=0){ if(ok_max(0,T)) return 1; } else{ if(ok_min(0,T)) return 1; } B += 4.0*T*c*c; C -= 4.0*T*T*c*c; if(A<=0){ if(ok_max(T,T*2)) return 1; } else{ if(ok_min(T,T*2)) return 1; } return 0;}int main(){ while(~scanf("%lf %lf %lf %lf", &x0, &y0, &c, &T)){ scanf("%d", &n); int ans=0; while(n--){ scanf("%lf %lf %lf %lf", &x, &y, &vx, &vy); ans += check(); } printf("%dn", ans); } return 0;}