N,M=map(int,input().split()) S=set() for _ in range(M): a,b=map(int,input().split()) S.add(b) print(N-len(S))