class UnionFind: def __init__(self, size): self.parent = list(range(size + 1)) # 1-based indexing self.size = [1] * (size + 1) def find(self, x): if self.parent[x] != x: self.parent[x] = self.find(self.parent[x]) return self.parent[x] def unite(self, x, y): x_root = self.find(x) y_root = self.find(y) if x_root == y_root: return if self.size[x_root] < self.size[y_root]: x_root, y_root = y_root, x_root self.parent[y_root] = x_root self.size[x_root] += self.size[y_root] def main(): import sys input = sys.stdin.read().split() idx = 0 N = int(input[idx]) idx += 1 M = int(input[idx]) idx += 1 students = 2 * N uf = UnionFind(students) for _ in range(M): a = int(input[idx]) idx += 1 b = int(input[idx]) idx += 1 uf.unite(a, b) seen = set() total_remainder = 0 for i in range(1, students + 1): root = uf.find(i) if root not in seen: seen.add(root) s = uf.size[root] total_remainder += s % 2 print(total_remainder // 2) if __name__ == "__main__": main()