#include using namespace std; int main(){ int N; cin >> N; vector> E(N); for (int i = 0; i < N - 1; i++){ int u, v; cin >> u >> v; u--; v--; E[u].push_back(v); E[v].push_back(u); } vector p(N, -1); vector> c(N); queue Q; Q.push(0); vector bfs; while (!Q.empty()){ int v = Q.front(); Q.pop(); bfs.push_back(v); for (int w : E[v]){ if (w != p[v]){ p[w] = v; c[v].push_back(w); Q.push(w); } } } reverse(bfs.begin(), bfs.end()); vector dp1(N), dp2(N); for (int v : bfs){ dp1[v] = 0; dp2[v] = 1; for (int w : c[v]){ dp1[v] += dp2[w]; dp2[v] += min(dp1[w], dp2[v]); } } cout << min(dp1[0], dp2[0]) << endl; }