N,M = map(int,input().split()) G = [[] for _ in range(N)] for i in range(M): A,B = map(int,input().split()) G[B].append(A) cnt = 0 for i in G: if not i: cnt+=1 print(cnt)