#include <bits/stdc++.h>
using namespace std;
const int maxn = 500010;
vector<int> leaves;
vector<vector<int> > root;
bool flag[maxn];
void solve(int use, int dep) {
  flag[use] = true;
  for (int i = 0; i < root[use].size(); i++) {
    int u = root[use][i];
    if (!flag[u]) {
      if (root[u].size() > 1) {
        solve(u, dep + 1);
      } else {
        leaves.push_back(dep);
      }
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  root.resize(n + 1);
  memset(flag, false, sizeof(flag));
  int r, s;
  int sum = 1;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &r, &s);
    if (r > s) swap(r, s);
    if (r != 1) {
      root[s].push_back(r);
    }
    root[r].push_back(s);
  }
  for (int i = 0; i < root[1].size(); i++) {
    int use = root[1][i];
    int time1 = 0;
    if (root[use].size()) {
      leaves.clear();
      solve(use, 2);
      sort(leaves.begin(), leaves.end());
      for (int j = 0; j < leaves.size(); j++) {
        time1 = max(time1 + 1, leaves[j]);
      }
    }
    sum = max(sum, time1);
  }
  printf("%d\n", sum);
  return 0;
}
