import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); long a = sc.nextLong(); long b = sc.nextLong(); long c = sc.nextLong(); long d = sc.nextLong(); int N = sc.nextInt(); HashSet set = new HashSet<>(); long det = a * d - b * c; det = Math.abs(det); if (det != 0) { for (int i = 0; i < N; ++i) { long x = sc.nextLong() % det; long y = sc.nextLong() % det; long s = ((d * x - c * y) % det + det) % det; long t = ((-b * x + a * y) % det + det) % det; set.add(s + ":" + t); } } else { if (a < 0) { a *= -1; b *= -1; } if (c < 0) { c *= -1; d *= -1; } long gcd = a != 0 ? gcd(a, c) : gcd(b, d); long div = a != 0 ? a / gcd : b / gcd; a /= div; b /= div; for (int i = 0; i < N; ++i) { long x = sc.nextLong(); long y = sc.nextLong(); long s = 0, t = 0; if (a != 0) { s = x % a; t = y - x / a * b; } else { t = y % b; s = x - y / b * a; } set.add(s + ":" + t); } } System.out.println(set.size()); } long gcd(long a, long b) { if (a > b) { return gcd(b, a); } if (a == 0) return b; return gcd(a, b % a); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }