#include <fstream>
using namespace std;
ifstream fin ("darb.in");
ofstream fout ("darb.out");
struct nod
{
int vf;
struct nod* urm;
};
typedef nod* LSI;
LSI L[100002], p;
int n, m, i, poz, maxim=0;
bool uz[100002];
void citire();
void inserare(LSI& L, int);
void dfs(int nod, int d);
int main()
{
citire();
dfs(1,1);
for(i=0; i<=n; i++)
uz[i]=0;
dfs(poz, 1);
fout<<maxim;
return 0;
}
void citire()
{
int x, y, i;
fin>>n;
while (fin>>x>>y)
{
inserare(L[x], y);
inserare(L[y], x);
}
}
void inserare(LSI& L, int x)
{
nod* q = new nod;
q->vf=x;
if(L==NULL)
L=q;
else
{
q->urm=L->urm;
L->urm=q;
}
}
void dfs(int x, int d)
{
int i;
LSI p=new nod;
uz[x]=1;
if(d>maxim)
{
maxim=d;
poz=x;
}
for(p=L[x]; p; p=p->urm)
{
if(uz[p->vf]==0)
dfs(p->vf, d+1);
}
}