#include <bits/stdc++.h>
using namespace std;
bool isvis[1000005] = {0};
vector<int> link[1000005];
vector<long long int> vec;
void dfs(int n, int d) {
  bool islf = true;
  isvis[n] = true;
  for (int i = 0; i < link[n].size(); i++) {
    if (!isvis[link[n][i]]) {
      islf = false;
      dfs(link[n][i], d + 1);
    }
  }
  if (islf) {
    vec.push_back(d);
  }
  return;
}
int main() {
  int n, n1, n2;
  cin.tie(NULL);
  cin.sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> n1 >> n2;
    link[n1].push_back(n2);
    link[n2].push_back(n1);
  }
  isvis[1] = true;
  long long int ans = numeric_limits<int>::min();
  for (int i = 0; i < link[1].size(); i++) {
    vec.clear();
    dfs(link[1][i], 0);
    sort(vec.begin(), vec.end());
    long long int btime = numeric_limits<int>::min();
    for (int j = 0; j < vec.size(); j++) {
      btime = max(btime + 1, vec[j]);
    }
    ans = max(ans, btime + 1);
  }
  cout << ans << endl;
  return 0;
}
