/* -*- coding: utf-8 -*- * * 1582.cc: No.1582 Vertexes vs Edges - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 100000; /* typedef */ typedef vector vi; /* global variables */ vi nbrs[MAX_N]; int ps[MAX_N], cis[MAX_N], dp[MAX_N][2]; /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); for (int i = 1; i < n; i++) { int u, v; scanf("%d%d", &u, &v); u--, v--; nbrs[u].push_back(v); nbrs[v].push_back(u); } ps[0] = -1; for (int u = 0; u >= 0;) { vi &nbru = nbrs[u]; int up = ps[u]; if (cis[u] < nbru.size()) { int v = nbru[cis[u]++]; if (v != up) { ps[v] = u; u = v; } } else { dp[u][0]++; if (up >= 0) { dp[up][0] += dp[u][1]; dp[up][1] += max(dp[u][0], dp[u][1]); } u = up; } } printf("%d\n", n - max(dp[0][0], dp[0][1])); return 0; }