#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 30;
struct edge {
  int to, next;
} G[maxn << 1];
int h[maxn], si;
void add(int u, int v) {
  G[si].to = v;
  G[si].next = h[u];
  h[u] = si++;
}
vector<int> p;
void dfs(int u, int f, int d) {
  int is = 0;
  for (int i = h[u]; ~i; i = G[i].next) {
    int v = G[i].to;
    if (v ^ f) {
      dfs(v, u, d + 1);
      is = 1;
    }
  }
  if (!is) p.push_back(d);
}
int solve(int u) {
  p.clear();
  dfs(u, 1, 1);
  int cur = -1;
  sort(p.begin(), p.end());
  for (int i = 0; i < p.size(); i++) {
    if (cur < p[i])
      cur = p[i];
    else
      cur++;
  }
  return cur;
}
int main() {
  int n;
  while (~scanf("%d", &n)) {
    memset(h, -1, sizeof h);
    si = 0;
    int u, v;
    for (int i = 0; i < n - 1; i++) {
      scanf("%d%d", &u, &v);
      add(u, v);
      add(v, u);
    }
    int ans = 0;
    for (int i = h[1]; ~i; i = G[i].next) ans = max(ans, solve(G[i].to));
    printf("%d\n", ans);
  }
  return 0;
}
