#include #include #include using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int N; vector> E; vector P; vector I; vector dp[2]; int main(){ cin >> N; E.resize(N); rep(i,N-1){ int u,v; cin >> u >> v; u--; v--; E[u].push_back(v); E[v].push_back(u); } P.assign(N,-1); I = {0}; rep(i,I.size()){ int p = I[i]; for(int e : E[p]) if(P[p] != e){ P[e] = p; I.push_back(e); } } rep(t,2) dp[t].assign(N,t); for(int i=N-1; i>=0; i--){ int p = I[i]; for(int e : E[p]) if(P[p] != e){ dp[0][p] += dp[1][e]; dp[1][p] += min(dp[1][e],dp[0][e]); } } int ans = min(dp[0][0],dp[1][0]); cout << ans << endl; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_inst;