#include <bits/stdc++.h>   using namespace std;   inline long long power(long long a, long long b) {     long long x = 1;     a = a % 1000000007ULL;     while (b) {       if (b & 1) x = (x * a) % 1000000007ULL;       a = (a * a) % 1000000007ULL;       b >>= 1;     }     return x;   }   inline long long inv(long long a) { return power(a, 1000000007ULL - 2); }   long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }   const int N = 2e5 + 5;   vector<int> adj[N];   int n, dis[N];   bool vis[N];   int cnt[N], p[N];   int tdis[N];   vector<int> d[N];   void dfs(int u, int dd, int par) {     vis[u] = true;     if (dd < 3)       tdis[u] = dd;     else       tdis[u] = N;     dis[u] = dd;     d[dd].push_back(u);     p[u] = par;     for (auto v : adj[u]) {       if (!vis[v]) dfs(v, dd + 1, u);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n;     int u, v;     for (int i = 1; i < n; i++) {       cin >> u >> v;       adj[u].push_back(v);       adj[v].push_back(u);     }     dfs(1, 0, 0);     int maxx = 0;     for (int i = 0; i < n; i++) {       if (d[i].size() == 0) break;       maxx = i;     }     int ans = 0;     for (int i = maxx; i > 1; i--) {       for (auto v : d[i]) {         if (dis[v] < 2 || tdis[v] == 2) continue;         ans++;         tdis[p[v]] = 2;         for (auto j : adj[p[v]]) tdis[j] = 2;       }     }     cout << ans << endl;     return 0;   }   