#include #include using namespace std; using namespace atcoder; #define rep(i, n) REP(i, 0, n) #define REP(i, s, e) for (ll i = (s); i < (ll)(e); i++) #define repr(i, n) REPR(i, n, 0) #define REPR(i, s, e) for (ll i = (ll)(s - 1); i >= (ll)(e); i--) #define all(r) r.begin(), r.end() #define rall(r) r.rbegin(), r.rend() using ll = long long; using vi = vector; using vl = vector; template bool chmax(T& a, const U& b) { if (a >= b) return false; a = b; return true; } template bool chmin(T& a, const U& b) { if (a <= b) return false; a = b; return true; } void yes_no(bool f, string yes = "Yes", string no = "No") { cout << (f ? yes : no) << "\n"; } void solve() { int n; cin >> n; vector es(n); vi deg(n); rep(i, n - 1) { int a, b; cin >> a >> b; --a; --b; es[a].emplace_back(b); es[b].emplace_back(a); deg[a]++; deg[b]++; } const ll inf = 1e18; vl dp(n, inf), ep(n, inf); auto dfs = [&](auto self, int cur, int par) -> void { int need = (deg[cur] + 1) / 2; ll sum_dp = 0, sum_ep = 0; vl v; v.reserve(deg[cur]); for (auto&& to : es[cur]) if (to != par) { self(self, to, cur); sum_dp += dp[to]; sum_ep += ep[to]; v.emplace_back(dp[to] - ep[to]); } if (v.empty()) { dp[cur] = 1; ep[cur] = 0; return; } sort(all(v)); ll tmp = sum_ep; rep(i, need) tmp += v[i]; dp[cur] = min(sum_ep + 1, tmp); ep[cur] = sum_ep; rep(i, need - 1) ep[cur] += v[i]; }; dfs(dfs, 0, -1); cout << dp[0] << '\n'; // rep(i, n) cout << dp[i] << " " << ep[i] << '\n'; } int main() { cin.tie(0); ios::sync_with_stdio(false); int t = 1; // cin >> t; rep(ti, t) solve(); return 0; }