N, M = map(int, input().split()) AB = [list(map(int, input().split())) for _ in range(M)] ans = [1 for _ in range(N)] for a, b in AB: a-=1 b-=1 ans[b] = 0 print(sum(ans))