# coding: utf-8 # Your code here! x = list(map(int, input().split())) num = int(input()) lst = [] for ls in range(num): lst.append(list(map (int ,input().split()))) ans = 0 for ele in lst: asm = 0 A = abs(abs(x[0]) - abs(x[1])) B = abs(abs(ele[0]) - abs(ele[1])) if B % A == 0: print ans = ans + 1 print(ans)