n,m=map(int,input().split()) in_degree=[0]*n for _ in range(m): a,b=map(int,input().split()) in_degree[b-1]+=1 print(in_degree.count(0))