# 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 print(lst) for ele in lst: asm = 0 A = abs(x[0] - x[1]) B = abs(ele[0] - ele[1]) if B == 0: continue elif B % A == 0: ans = ans + 1 print(ans)