N, M = map(int, input().split()) S = set() for i in range(M): A, B = map(int, input().split()) S.add(B) print(N - len(S))