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