#include using namespace std; typedef long long ll; #define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++) #define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++) #define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--) #define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) ((ll)(x).size()) #define len(x) ((ll)(x).length()) #define endl "\n" ll n; vector> g; vector> dp; void dfs(ll v, ll p = -1) { dp[v][0] = 1; dp[v][1] = 0; for(auto &u : g[v]) { if (u == p) continue; dfs(u, v); dp[v][0] += max(dp[u][0] - 1, dp[u][1]); dp[v][1] += max(dp[u][0], dp[u][1]); } } int main() { cin.tie(0); ios::sync_with_stdio(false); // ifstream in("input.txt"); // cin.rdbuf(in.rdbuf()); cin >> n; g.resize(n); rep(i, n - 1) { ll u, v; cin >> u >> v; u--; v--; g[u].push_back(v); g[v].push_back(u); } dp.resize(n, vector(2)); dfs(0); cout << max(dp[0][0], dp[0][1]) << endl; return 0; }