import sys import math def main(): a, b, c, d = map(int, sys.stdin.readline().split()) N = int(sys.stdin.readline()) points = [tuple(map(int, sys.stdin.readline().split())) for _ in range(N)] determinant = a * d - b * c if determinant != 0: g = abs(determinant) groups = set() for x, y in points: s = (d * x - c * y) % g t = (-b * x + a * y) % g groups.add((s, t)) print(len(groups)) else: # Check if both vectors are zero vectors (but problem states they are not) # Since (a,b) and (c,d) are non-zero and parallel, compute based on (a,b) # Compute gcd of a and b g = math.gcd(a, b) if g == 0: g = math.gcd(c, d) a, b = c, d a_prime = a // g b_prime = b // g groups = set() for x, y in points: val = b_prime * x - a_prime * y groups.add(val) print(len(groups)) if __name__ == "__main__": main()