# coding: utf-8 # Your code here! import sys sys.setrecursionlimit(10**6) readline = sys.stdin.readline #文字列入力のときは注意 from math import gcd a,b,c,d = [int(i) for i in readline().split()] n = int(input()) xy = [[int(i) for i in readline().split()] for _ in range(n)] def heikouidou(x,y,pp,qq,g,h): #(e,f)に沿って(g,h)以上のぎりぎり m = (x*h-y*g)//(h*pp-g*qq) x -= m*pp y-= m*qq return (x,y) if a*d == b*c: if a==0 and c==0: g = gcd(b,d) else: g = gcd(a,c) # print(a,b,c,d,g) # assert b%g==0 p,q = a//g, b//g s = set() for x,y in xy: s.add(heikouidou(x,y,p,q,-q,p)) print(len(s)) # print(s) exit() s = set() for x,y in xy: # print(x,y) x,y = heikouidou(x,y,a,b,c,d) # print(x,y) x,y = heikouidou(x,y,c,d,a,b) # print(x,y) s.add((x,y)) print(len(s)) #print(s) exit()