N, M = map(int, input().split()) ans = [1] * N for i in range(M): a, b = map(int, input().split()) ans[b - 1] = 0 print(ans.count(1))