#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <bits/stdc++.h>
#define M 100005
using namespace std;
ifstream f("darb.in");
ofstream g("darb.out");
vector <int> a[M];
int n, m, s, k, viz[M];
queue <int> q;
void bfs(int s)
{
memset(viz, -1, sizeof(viz));
q.push(s); viz[s]=0;
while ( !q.empty() )
{
k=q.front();
q.pop();
for (int i=0; i<a[k].size(); i++)
if ( viz[ a[k][i] ]== -1 )
{
viz[ a[k][i] ] = viz[k]+1;
q.push( a[k][i] );
}
}
}
int main()
{
int i, j, x, y;
f>>n;
for (i=1; i<=n-1; i++)
{
f>>x>>y;
a[x].push_back(y);
a[y].push_back(x);
}
int max1=-1;
for (i=1; i<=n; i++)
{
bfs(i);
for (j=1; j<=n; j++) if (max1<viz[j]) max1=viz[j];
}
g<<max1+1;
return 0;
}