#include using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair P; int main(){ int n; cin >> n; vector> g(n); rep(i,n-1) { int u, v; cin >> u >> v; u--; v--; g[u].emplace_back(v); g[v].emplace_back(u); } vector> dp(n,vector(2)); auto dfs = [&](auto& f, int p, int u)->void{ for (auto v : g[u]) { if (v == p) continue; f(f, u, v); } int res0 = 1, res1 = 0; for (auto v : g[u]) { if (v == p) continue; res0 += max(dp[v][0]-1, dp[v][1]); res1 += max(dp[v][0], dp[v][1]); } dp[u][0] = res0; dp[u][1] = res1; }; dfs(dfs,-1,0); cout << max(dp[0][0], dp[0][1]) << endl; return 0; }