#include using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define all(x) (x).begin(), (x).end() using ll = long long; using pii = pair; using vi = vector; using vvi = vector>; const ll inf = 1e9; int tree[400005]; vi to[100005]; void add(int i,int a){ int u=i+tree[0]; tree[u]+=a; while(u>1){ u/=2; tree[u]=min(tree[u*2],tree[u*2+1]); } } void update(int i,int a){ int u=i+tree[0]; tree[u]=a; while(u>1){ u/=2; tree[u]=min(tree[u*2],tree[u*2+1]); } } int mini(){ int u=1; while(u>n; tree[0]=1; while(tree[0]>u>>v; u--;v--; to[u].push_back(v); to[v].push_back(u); tree[u+tree[0]]++; tree[v+tree[0]]++; } // rep(i,tree[0]) cout<=1;u--) tree[u]=min(tree[u*2],tree[u*2+1]); int ans=1; while(tree[1]==1){ int d=0; int i=mini(); for(int j:to[i]) if(tree[j+tree[0]]!=inf){ d=j; break; } i=d; ans+=tree[i+tree[0]]-1; // cout<