#include #include using namespace std; vector path[100010]; bool visited[100010]; pair dfs(int v) { visited[v] = true; vector> res; for (int sv : path[v]) { if (visited[sv]) continue; res.push_back(dfs(sv)); } pair ret = make_pair(0, 1); for (auto p : res) { ret.first += max(p.first, p.second); ret.second += max(p.first, p.second - 1); } return ret; } int main() { int N; cin >> N; for (int i = 0; i < N - 1; ++i) { int u, v; cin >> u >> v; --u, --v; path[u].push_back(v); path[v].push_back(u); } pair ret = dfs(0); cout << max(ret.first, ret.second) << endl; return 0; }