import math from collections import defaultdict a, b, c, d = map(int, input().split()) N = int(input()) points = [tuple(map(int, input().split())) for _ in range(N)] D = a * d - b * c if D != 0: abs_D = abs(D) groups = defaultdict(int) for x, y in points: r1 = (d * x - c * y) % abs_D r2 = (-b * x + a * y) % abs_D groups[(r1, r2)] += 1 print(len(groups)) else: # Compute direction vector for the 1D lattice g = math.gcd(a, b) if a == 0 and b == 0: # This case is invalid as per problem constraints, so not possible pass gx = a // g gy = b // g groups = defaultdict(int) for x, y in points: s = gy * x - gx * y groups[s] += 1 print(len(groups))