#include using namespace std; //* ATCODER #include using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template T max(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template T min(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template T sum(vector &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector ikeru(n, vector(0)); rep(i,0,n-1){ int u, v; cin >> u >> v; u--; v--; ikeru[u].push_back(v); ikeru[v].push_back(u); } vector dp0(n); vector dp1(n); auto dfs1 = [&](auto self, int i, int p) -> void { dp0[i] = 0; dp1[i] = 1; for (int j: ikeru[i]){ if (j == p) continue; self(self, j, i); dp0[i] += max(dp1[j], dp0[j]); dp1[i] += dp0[j]; } return; }; dfs1(dfs1, 0, -1); vector ans(n); auto dfs2 = [&](auto self, int i, int p, int up0, int up1) -> void { vector rui_left0 = {0}; vector rui_left1 = {0}; int now_left0 = 0; int now_left1 = 0; int cnt = 0; for (int j: ikeru[i]){ if (j == p) continue; now_left0 += max(dp0[j], dp1[j]); now_left1 += dp0[j]; cnt++; rui_left0.push_back(now_left0); rui_left1.push_back(now_left1); } reverse(ikeru[i].begin(), ikeru[i].end()); now_left0 = 0; now_left1 = 0; for (int j: ikeru[i]){ if (j == p) continue; cnt--; self(self, j, i, max(up0, up1) + rui_left0[cnt] + now_left0, up0 + rui_left1[cnt] + now_left1 + 1 ); now_left0 += max(dp0[j], dp1[j]); now_left1 += dp0[j]; } ans[i] = now_left1 + up0 + 1; }; dfs2(dfs2, 0, -1, 0, 0); /* rep(i,0,n){ cout << ans[i] << ' '; }cout << '\n'; */ cout << min(ans) << '\n'; }