#include using namespace std; using ll = long long; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a par, siz, t; UnionFind(int N) : par(N), siz(N,1), t(N,0){ rep(i,N) par[i] = i; } int root(int x){ if(par[x]==x) return x; return par[x] = root(par[x]); } bool unite(int x,int y){ x = root(x); y = root(y); if(x==y){ t[x]++; return false; } if(siz[x]> n >> m; vector u(m),v(m); rep(i,m){ cin >> u[i] >> v[i]; u[i]--; v[i]--; } reverse(all(u)); reverse(all(v)); UnionFind uf(n); int ans = 0; rep(i,m) uf.unite(u[i], v[i]); cout << uf.t[uf.root(0)] << '\n'; return 0; }