import sys readline=sys.stdin.readline write=sys.stdout.write N,M=map(int,readline().split()) indegree=[0]*N for _ in range(M): A,B=map(int,readline().split()) B-=1 indegree[B]=1 ans=indegree.count(0) print(ans)