N,M=map(int,input().split()) s=set() for i in range(M): A,B=map(int,input().split()) s.add(B) print(N-len(s))