#include <bits/stdc++.h>
using namespace std;
const int N = 555555;
int n;
vector<int> vec, v[N];
void dfs(int p, int x, int d = 0) {
  if (v[x].size() == 1) vec.push_back(d);
  for (__typeof((v[x]).begin()) it = (v[x]).begin(); it != (v[x]).end(); it++) {
    int u = *it;
    if (u != p) {
      dfs(x, u, d + 1);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  int ans = 0;
  for (__typeof((v[1]).begin()) it = (v[1]).begin(); it != (v[1]).end(); it++) {
    int x = *it;
    vec.clear();
    dfs(1, x);
    int res = -1e9;
    sort(vec.begin(), vec.end());
    for (__typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); it++) {
      int x = *it;
      res = max(res + 1, x);
    }
    ans = max(ans, res + 1);
  }
  printf("%d\n", ans);
  return 0;
}
