a,b=map(int,input().split())c=int(input())z=[]X=0for j in range(c): z=list(map(int,input().split())) A=z.count(a) B=z.count(-a) A=A-B C=z.count(b) D=z.count(-b) B=C-D if A>=1 and B>=1: X+=1print(X)