#include using namespace std; typedef long long ll; #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() const int MAX = 1e9; const int MIN = -1*1e9; const ll MAXLL = 1e18; const ll MINLL = -1*1e18; vector F(200010); vector> G(200010); vector DP(200010,vector(2)); void DFS(int n, int v) { for(auto x : G[n]) { if(F[x] || x == v) continue; DFS(x,n); DP[n][0] += max(DP[x][0],DP[x][1]); DP[n][1] += max(DP[x][0]+1,DP[x][1]); } if(G[n].size() == 1 && G[n][0] == v) DP[n][1] = MIN; //cout << n << " " << DP[n][0] << " " << DP[n][1] << endl; return; } int main() { int N; cin >> N; for(int i = 0; i < N-1; i++) { int A,B; cin >> A >> B; G[A].push_back(B); G[B].push_back(A); } DFS(1,-1); cout << max(DP[1][0]+1,DP[1][1]) << endl; return 0; }