#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
vector<int> q;
void dfs(int v, int p = -1, int h = 0) {
  bool is = false;
  for (int i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (to != p) {
      dfs(to, v, h + 1);
      is = true;
    }
  }
  if (!is) q.push_back(h);
}
int get(int v, int p) {
  q.clear();
  dfs(v, p);
  sort(q.begin(), q.end());
  for (int i = 0; i < q.size(); ++i) {
    if (i) q[i] = max(q[i - 1] + 1, q[i]);
  }
  return q.back();
}
void solve() {
  int n;
  scanf("%d", &n);
  g.resize(n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int ans = 0;
  for (int i = 0; i < g[0].size(); ++i) {
    ans = max(ans, get(g[0][i], 0) + 1);
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
