#include <bits/stdc++.h> using namespace std; int main(){ int pn; while(cin>>pn){ vector<int>p[pn]; int tem; int temp; for(int sdf=0;sdf<pn-1;sdf++){ cin>>tem; cin>>temp; p[tem].push_back(temp); p[temp].push_back(tem); } vector<int>ch; for(int erf=0;erf<pn;erf++){ if(p[erf].size()==1){ch.push_back(erf); } } vector<int>check; int start;int co=0; int went[pn]; int br=0; vector<int>check2; int big=0; for(int e=0;e<ch.size()-1;e++){ check.push_back(ch[e]); for(int yui=0;yui<pn;yui++){ went[yui]=0; } co=0; went[ch[e]]=1; while(true){ br=0; for(int i=0;i<check.size();i++){ for(int j=0;j<p[check[i]].size();j++){ if(went[p[check[i]][j]]==0){ went[p[check[i]][j]]=1; br=1; // another check push back. check2.push_back(p[check[i]][j]); } } } check.clear(); if(br==0)break; co++; for(int wert=0;wert<check2.size();wert++){ check.push_back(check2[wert]); } check2.clear(); } if(co>big){big=co;} } cout<<big<<endl; } }