n,m=map(int,input().split()) a=0 C=[] for i in range(n): b,c=map(int,input().split()) if c in C:a+=1 else:C.append(c) print(a)