use ac_library::Dsu; use std::io::Read; fn main() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut it = s.split_ascii_whitespace().map(|x| x.parse::().unwrap()); let n = it.next().unwrap(); let m = it.next().unwrap(); let mut d = Dsu::new(n); for _ in 0..m { let u = it.next().unwrap(); let v = it.next().unwrap(); d.merge(u, v); } println!("{}", (0..n).filter(|&i| d.leader(i) == i).count()); }