#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
const int N = 1e5 + 9;
int n, ans;
bool vis[N];
vector<int> e[N];
void dfs(int S, int step) {
for (auto i : e[S]) {
if (!vis[i]) {
vis[i] = true;
dfs(i, step + 1);
vis[i] = false;
}
}
ans = max(ans, step);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
#ifdef BIG_BANANA_A_BIG_BANANA_YOUR_FEEL_VERY_WORDFUL
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
cin >> n;
for (int i = 1; i < n; i++) {
int x, y;
cin >> x >> y;
e[x].push_back(y);
e[y].push_back(x);
}
for (int i = 1; i <= n; i++) {
vis[i] = true;
dfs(i, 0);
vis[i] = false;
}
cout << ans << endl;
return 0;
}