#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 5;
vector<int> E[MAXN], rk;
int dep[MAXN];
void dfs(int now, int f = 1, int dp = 1) {
  if (E[now].size() == 1) {
    rk.push_back(dp);
    return;
  }
  for (auto v : E[now]) {
    if (v == f) continue;
    dfs(v, now, dp + 1);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    E[u].push_back(v);
    E[v].push_back(u);
  }
  int ans = 0;
  for (int v : E[1]) {
    rk.clear();
    dfs(v);
    sort(rk.begin(), rk.end());
    int last = 0;
    for (int i : rk) {
      int now = max(last + 1, i);
      ans = max(ans, now);
      last = now;
    }
  }
  printf("%d\n", ans);
  return 0;
}
