import java.util.Scanner;
public class Main {
public static void main
(String[] args
) { Scanner scanner
= new Scanner
(System.
in); int l = scanner.nextInt();
int n = scanner.nextInt();
int k = scanner.nextInt();
int count = 0;
for(int i=0; i<n; i++) {
int x1 = scanner.nextInt();
int y1 = scanner.nextInt();
int x2 = scanner.nextInt();
int y2 = scanner.nextInt();
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
)*Math.
max(y2, y1
)&&-c
*b
>=(b
*b
+a
*a
)*Math.
min(y2, y1
))) count++;
}
}
System.
out.
println(count
/k
+1); }
}
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwoKcHVibGljIGNsYXNzIE1haW4gewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHsKCQlTY2FubmVyIHNjYW5uZXIgPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwoJCWludCBsID0gc2Nhbm5lci5uZXh0SW50KCk7CgkJaW50IG4gPSBzY2FubmVyLm5leHRJbnQoKTsKCQlpbnQgayA9IHNjYW5uZXIubmV4dEludCgpOwoJCWludCBjb3VudCA9IDA7CgkJZm9yKGludCBpPTA7IGk8bjsgaSsrKSB7CgkJCWludCB4MSA9IHNjYW5uZXIubmV4dEludCgpOwoJCQlpbnQgeTEgPSBzY2FubmVyLm5leHRJbnQoKTsKCQkJaW50IHgyID0gc2Nhbm5lci5uZXh0SW50KCk7CgkJCWludCB5MiA9IHNjYW5uZXIubmV4dEludCgpOwoJCQlpZih4MSp4MSt5MSp5MTw9bCpsfHx4Mip4Mit5Mip5Mjw9bCpsKQoJCQkJY291bnQrKzsKCQkJZWxzZSB7CgkJCSAJaW50IGEsIGIsIGM7CgkJICAgIAlpbnQgZGVsd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