#include <bits/stdc++.h>
using namespace std;
int N;
vector<vector<int> > adj;
vector<vector<int> > leaf;
void dfs(int u, int p, int c, int dep) {
  bool ok = false;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == p) continue;
    ok = true;
    dfs(v, u, (p == -1 ? i : c), dep + 1);
  }
  if (!ok) leaf[c].push_back(dep);
}
int main() {
  scanf("%d", &N);
  adj.resize(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  leaf.resize(adj[0].size());
  dfs(0, -1, 0, 0);
  int ans = 0;
  for (int i = 0; i < adj[0].size(); i++) {
    sort(leaf[i].begin(), leaf[i].end());
    int mx = 0;
    int t = 0;
    for (int j = leaf[i].size(); j--;) {
      mx = max(mx, t + leaf[i][j]);
      t++;
    }
    ans = max(ans, mx);
  }
  printf("%lld", ans);
}
