#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> v[500100];
vector<int> c;
void go(int cr, int pa, int d) {
  for (int i = 0; i < v[cr].size(); i++) {
    if (v[cr][i] != pa) go(v[cr][i], cr, d + 1);
  }
  if (v[cr].size() == 1 && cr != 1) {
    c.push_back(d);
    return;
  }
}
int ans;
void get() {
  sort(c.begin(), c.end());
  for (int i = 1; i < c.size(); i++) {
    c[i] = max(c[i - 1] + 1, c[i]);
  }
  ans = max(c[c.size() - 1] + 1, ans);
  c.clear();
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 0; i < v[1].size(); i++) {
    go(v[1][i], 1, 0);
    get();
  }
  cout << ans;
  return 0;
}
