#include using namespace std; #define rep(i, m, n) for (int i = m; i < n; ++i) int N; vector> G; int dp[101010][2]; void dfs(int cur, int pre = -1) { dp[cur][0] = 1; dp[cur][1] = 0; for(auto &to : G[cur]) { if(to == pre) continue; dfs(to, cur); dp[cur][0] += max(dp[to][0] - 1, dp[to][1]); dp[cur][1] += max(dp[to][0], dp[to][1]); } } int main() { cin >> N; G.resize(N); rep(i, 0, N - 1) { int x, y; cin >> x >> y; x--, y--; G[x].push_back(y); G[y].push_back(x); } dfs(0); cout << max(dp[0][0], dp[0][1]) << endl; return 0; }