#include using namespace std; #include using namespace atcoder; #define rep(i, n) for(int i=0;i<(n);++i) #define rep1(i, n) for(int i=1;i<=(n);i++) #define ll long long using mint = modint; using P = pair; using lb = long double; #ifdef LOCAL # include # define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else # define dbg(...) (static_cast(0)) #endif int n; vector> dp(2e5+5, vector(2)); vector ans(2e5+5); vector> g(2e5+5); int m; //0 白 1 黒 vector dfs(int u, int p=-1) { dp[u][0] = 0; dp[u][1] = 1; for(int v : g[u]){ if(v==p) continue; dfs(v,u); dp[u][0] += max(dp[v][0], dp[v][1]); dp[u][1] += dp[v][0]; } return dp[u]; }; void dfs2(int u, int p=-1){ int N = g[u].size(); if(N==0) return; vector> l(N, vector(2)); vector> r(N, vector(2)); ans[u] = 1; rep(i,N){ ans[u] += dp[g[u][i]][0]; } l[0][0] = dp[g[u][0]][0]; l[0][1] = max(dp[g[u][0]][0],dp[g[u][0]][1]); r[N-1][0] = dp[g[u][N-1]][0]; r[N-1][1] = max(dp[g[u][N-1]][0],dp[g[u][N-1]][1]); rep(i,N){ int v = g[u][i]; if(i-1>=0) { l[i][0] = l[i-1][0]+dp[v][0]; l[i][1] = l[i-1][1]+max(dp[v][0],dp[v][1]); } } for(int i=N-1;i>=0;i--){ int v = g[u][i]; if(i+1=0) { dp[u][1] += l[i-1][0]; dp[u][0] += max(l[i-1][1],l[i-1][0]); } if(i+1> n; if(n==1){ cout<<1<> u >> v; --u;--v; g[u].push_back(v); g[v].push_back(u); } dfs(0); dfs2(0); cout<<*min_element(ans.begin(),ans.begin()+n)<