#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500010;
int n, depth[MAXN];
vector<int> graph[MAXN], ex;
void dfs(int v, int p) {
  depth[v] = depth[p] + 1;
  bool good = 0;
  for (int u : graph[v]) {
    if (u != p) {
      dfs(u, v);
      good = 1;
    }
  }
  if (!good) ex.push_back(depth[v]);
}
int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  depth[0] = 0;
  int ans = 0;
  for (auto v : graph[0]) {
    ex.clear();
    dfs(v, 0);
    sort(ex.begin(), ex.end());
    int extra = 0;
    for (int i : ex) {
      if (extra < i)
        extra = i;
      else
        extra++;
    }
    ans = max(ans, extra);
  }
  cout << ans << "\n";
  return 0;
}
