#include using namespace std; map,int> memo; int DFS(vector> &G,int v,bool cut,int p = -1){ if(memo.count(make_pair(v,cut))) return memo[make_pair(v,cut)]; int res = 0; for(int x : G[v]){ if(x==p) continue; if(cut) res += max(DFS(G,x,true,v)+(int)G[x].size()-2,DFS(G,x,false,v)); else res += max(DFS(G,x,true,v)+(int)G[x].size()-1,DFS(G,x,false,v)); } memo[make_pair(v,cut)] = res; return res; } int main(){ int N; cin >> N; vector> G(N,vector(0)); for(int i = 0;i < N-1;i++){ int U,V; cin >> U >> V; U--; V--; G[U].push_back(V); G[V].push_back(U); } cout << 1+max(DFS(G,0,true)+(int)G[0].size()-1,DFS(G,0,false)) << endl; }