#include using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define INF ((1LL<<62)-(1LL<<31)) #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() typedef long long ll; typedef pair pl; ll dfs(vector> &g,int pos,int par,priority_queue> &pq) { ll cnt=0,ret=1; for(auto nv:g[pos]) { if(nv==par) continue; cnt++; ll res=dfs(g,nv,pos,pq); pq.push(res); } if(cnt==0) return 1; rep(i,2) { if(pq.empty()) break; ret+=pq.top(); pq.pop(); } return ret; } int main() { ll n; cin >> n; vector> g(n,vector ()); vector deg(n,0); rep(i,n-1) { int u,v; cin >> u >> v; u--; v--; g[u].push_back(v); g[v].push_back(u); } priority_queue> pq; ll ans=dfs(g,0,-1,pq); cout << ans << endl; return 0; }