#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 5;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
const long long X = 316;
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
vector<int> myvec, edge[N];
bool vis[N];
void dfs(int u, int height) {
  vis[u] = 1;
  bool is_leaf = true;
  for (auto v : edge[u])
    if (vis[v] == 0) dfs(v, height + 1), is_leaf = false;
  if (is_leaf) myvec.push_back(height);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cerr.tie(nullptr);
  int n;
  cin >> n;
  for (long long i = 1; i <= n - 1; i++) {
    int x, y;
    cin >> x >> y;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  vis[1] = 1;
  int ans = 0;
  for (auto u : edge[1]) {
    myvec.clear();
    dfs(u, 0);
    sort(myvec.begin(), myvec.end());
    int m = myvec.size();
    for (long long i = 1; i <= m - 1; i++)
      myvec[i] = max(myvec[i], myvec[i - 1] + 1);
    ans = max(ans, myvec.back() + 1);
  }
  cout << ans;
}
