#include <bits/stdc++.h>
using namespace std;
const int maxn = 500100;
vector<int> pos[maxn];
int a[maxn], tot;
void dfs(int u, int father, int deep) {
  if (pos[u].size() == 1) {
    a[tot++] = deep;
    return;
  }
  for (int i = 0; i < pos[u].size(); i++) {
    if (father != pos[u][i]) dfs(pos[u][i], u, deep + 1);
  }
  return;
}
int main() {
  int i, n;
  int u, v;
  while (~scanf("%d", &n)) {
    for (i = 1; i <= n; i++) pos[i].clear();
    for (i = 1; i < n; i++) {
      scanf("%d %d", &u, &v);
      pos[u].push_back(v);
      pos[v].push_back(u);
    }
    int ans = 0;
    for (i = 0; i < pos[1].size(); i++) {
      tot = 0;
      dfs(pos[1][i], 1, 1);
      sort(a, a + tot);
      for (int j = 1; j < tot; j++) a[j] = max(a[j - 1] + 1, a[j]);
      ans = max(ans, a[--tot]);
    }
    printf("%d\n", ans);
  }
  return 0;
}
