from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline N,M = map(int,input().split()) ind = [0]*N for _ in range(M): a,b = map(int,input().split()) a -= 1 b -= 1 ind[b] += 1 print(sum(ind[i]==0 for i in range(N)))