#include using namespace std; signed main() { ios::sync_with_stdio(false); int N; cin >> N; vector> G(N); for (int i = 0; i + 1 < N; ++i) { int u, v; cin >> u >> v; G[u - 1].push_back(v - 1); G[v - 1].push_back(u - 1); } vector> dp(2, vector(N)); function dfs = [&](int u, int fa) { for (int v : G[u]) { if (v == fa) continue; dfs(v, u); dp[0][u] += max(dp[0][v] - 1, dp[1][v]); dp[1][u] += max(dp[0][v], dp[1][v]); } ++dp[0][u]; }; dfs(0, -1); cout << max(dp[0][0], dp[1][0]) << endl; return 0; }