class UnionFind: def __init__(self, n): self.par = [i for i in range(n + 1)] self.rank = [0] * (n + 1) # search def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] # unite def union(self, x, y): x = self.find(x) y = self.find(y) if self.rank[x] < self.rank[y]: self.par[x] = y else: self.par[y] = x if self.rank[x] == self.rank[y]: self.rank[x] += 1 # check def same_check(self, x, y): return self.find(x) == self.find(y) n, m = map(int, input().split()) ab_list = [tuple(map(int, input().split())) for _ in range(m)] uf = UnionFind(n) for a, b in ab_list: uf.union(a, b) p_count = [0] * (n + 1) for i in range(n): p = uf.find(i + 1) p_count[p] += 1 res = n for i in range(n): res -= p_count[i + 1] // 2 print(res)