import sys input = sys.stdin.buffer.readline N, M = map(int, input().split()) in_deg = [0] * N for _ in range(M): a, b = tuple(int(x) - 1 for x in input().split()) in_deg[b] += 1 print(in_deg.count(0))