using namespace std; #include #include #include int dp[100009][2]; vector E[100009]; void dfs(int cu, int pa = -1) { dp[cu][1] = 1; for (auto to : E[cu]) if(to!=pa){ dfs(to, cu); dp[cu][0] += max(dp[to][0], dp[to][1]); dp[cu][1] += max(dp[to][0], dp[to][1] - 1); } } int main() { int N; cin >> N; for (int i = 0; i < N - 1; i++) { int x, y; cin >> x >> y; x--, y--; E[x].push_back(y); E[y].push_back(x); } dfs(0); cout << max(dp[0][0], dp[0][1]); }