#include <bits/stdc++.h>
using namespace std;
int dp, n, i, a, b, pre[2000100], p[2000100], tt[2000100], j;
int mi, ma, sum, ans, cnt[2000100];
void link(int x, int y) {
  dp++;
  pre[dp] = p[x];
  p[x] = dp;
  tt[dp] = y;
}
void dfs(int x, int fa, int deep) {
  int i, flag = 0;
  i = p[x];
  while (i) {
    if (tt[i] != fa) {
      dfs(tt[i], x, deep + 1);
      flag = 1;
    }
    i = pre[i];
  }
  if (!flag) {
    mi = min(mi, deep);
    ma = max(ma, deep);
    sum++;
    cnt[deep]++;
  }
}
int main() {
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    link(a, b);
    link(b, a);
  }
  i = p[1];
  while (i) {
    mi = 0x37373737;
    ma = 0;
    sum = 0;
    dfs(tt[i], 1, 1);
    for (j = mi; j <= ma + sum; j++)
      if (cnt[j]) {
        ans = max(ans, j);
        cnt[j + 1] += (cnt[j] - 1);
        cnt[j] = 0;
      }
    i = pre[i];
  }
  printf("%d\n", ans);
}
