#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long MAX = 5100000; const long long INF = 1LL << 60; const long long mod = 1000000007LL; //const long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; int n; vector> g; vector> dp; void dfs(int cur, int pre) { for (auto next : g[cur]) { if (next == pre) continue; dfs(next, cur); } int re = 1; int er = 0; for (auto next : g[cur]) { if (next == pre) continue; er += max(dp[next][0], dp[next][1]); re += max(dp[next][0] - 1, dp[next][1]); } dp[cur][0] = re; dp[cur][1] = er; } int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ scanf("%d", &n); g = vector>(n); dp = vector>(n, vector(2)); for (int i = 0; i < n - 1; i++) { int u, v; scanf("%d %d", &u, &v); u--; v--; g[u].emplace_back(v); g[v].emplace_back(u); } dfs(0, -1); cout << max(dp[0][0], dp[0][1]) << endl; return 0; }