a, b, c, d = map(int, input().split()) D = a * d - b * c N = int(input()) points = [tuple(map(int, input().split())) for _ in range(N)] from collections import defaultdict counter = defaultdict(int) if D != 0: mod = abs(D) for x, y in points: val1 = (d * x - c * y) % mod val2 = (-b * x + a * y) % mod counter[(val1, val2)] += 1 else: if a == 0 and b != 0: mod = b for x, y in points: ry = y % mod counter[(x, ry)] += 1 elif b == 0 and a != 0: mod = a for x, y in points: rx = x % mod counter[(y, rx)] += 1 else: for x, y in points: param = b * x - a * y counter[param] += 1 print(len(counter))