#include <iostream>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int l, n, k, count=0;
cin >> l >> n >> k;
for(int i=0; i<n; i++)
{
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
if(x1*x1+y1*y1<=l*l||x2*x2+y2*y2<=l*l)
count++;
else
{
int a, b, c;
int deltaX=x2-x1;
int deltaY=y2-y1;
a=deltaY;
b=-deltaX;
c=y1*deltaX-x1*deltaY;
if(c*c<=l*l*(a*a+b*b)&&(-c*b<=(b*b+a*a)*max(y2, y1)&&-c*b>=(b*b+a*a)*min(y2, y1)))
count++;
}
}
cout << count/k+1 << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7Cglpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKCWNpbi50aWUoMCk7CglpbnQgbCwgbiwgaywgY291bnQ9MDsKCWNpbiA+PiBsID4+IG4gPj4gazsKCWZvcihpbnQgaT0wOyBpPG47IGkrKykKCXsKCQlpbnQgeDEsIHkxLCB4MiwgeTI7CgkJY2luID4+IHgxID4+IHkxID4+IHgyID4+IHkyOwoJCWlmKHgxKngxK3kxKnkxPD1sKmx8fHgyKngyK3kyKnkyPD1sKmwpCgkJCWNvdW50Kys7CgkJZWxzZQoJCXsKCQkJaW50IGEsIGIsIGM7CgkJCWludCBkZWx0YVg9eDIteDE7CgkJCWludCBkZWx0YVk9eTIteTE7CgkJCWE9ZGVsdGFZOwoJCQliPS1kZWx0YVg7CgkJCWM9eTEqZGVsdGFYLXgxKmRlbHRhWTsKCQkJaWYoYypjPD1sKmwqKGEqYStiKmIpJiYoLWMqYjw9KGIqYithKmEpKm1heCh5MiwgeTEpJiYtYypiPj0oYipiK2EqYSkqbWluKHkyLCB5MSkpKQoJCQkJY291bnQrKzsKCQl9Cgl9Cgljb3V0IDw8IGNvdW50L2srMSA8PCBlbmRsOyAKCXJldHVybiAwOwp9