#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int mod = 1000000007; struct mint { typedef long long ll; ll x; mint(ll x=0):x((x%mod+mod)%mod){} mint operator-() const { return mint(-x);} mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;} mint operator+(const mint a) const { return mint(*this) += a;} mint operator-(const mint a) const { return mint(*this) -= a;} mint operator*(const mint a) const { return mint(*this) *= a;} mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod-2);} mint& operator/=(const mint a) { return *this *= a.inv();} mint operator/(const mint a) const { return mint(*this) /= a;} }; istream& operator>>(istream& is, mint& a) { return is >> a.x;} ostream& operator<<(ostream& os, const mint& a) { return os << a.x;} int n; vector> g; int dp[100010][2]; bool done[100010][2]; int dfs(int v, int c, int p) { //printf("dfs(%d, %d, %d)\n", v+1, c, p+1); if (done[v][c]) return dp[v][c]; done[v][c] = true; if (c == 0) { int res = 0; for (int u : g[v]) if (u != p) res += max(dfs(u, 1, v), dfs(u, 0, v)); return dp[v][c] = res; } else { int res = 1; for (int u : g[v]) if (u != p) res += max(dfs(u, 1, v) -1, dfs(u, 0, v)); return dp[v][c] = res; } } int main() { cin >> n; g.resize(n); for (int i = 0; i < n-1; i++) { int a, b; cin >> a >> b; a--, b--; g[a].push_back(b); g[b].push_back(a); } cout << max(dfs(0, 1, -1), dfs(0, 0, -1)) << endl; }