n,m=map(int,input().split()) e=[1]*n for i in range(m): a,b=map(int,input().split()) a-=1 b-=1 e[b]=0 print(sum(e))