def main(): n, m = map(int, input().split()) st = set() for _ in range(m): a, b = map(int, input().split()) st.add(b) ans = n - len(st) print(ans) if __name__ == "__main__": main()