def main(): N, M = map(int, input().split()) nodes = {idx for idx in range(1, N + 1)} for _ in range(M): _, B = map(int, input().split()) nodes.discard(B) print(len(nodes)) if __name__ == "__main__": main()