#include <bits/stdc++.h>
using namespace std;
const int MX = 500005;
vector<int> adj[MX];
int v[MX];
int cnt;
int n;
void dfs(int u, int fa, int stp) {
  if (adj[u].size() == 1) {
    v[cnt++] = stp;
    return;
  }
  for (int j = 0; j < adj[u].size(); j++) {
    int v = adj[u][j];
    if (v != fa) {
      dfs(v, u, stp + 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int res = 0;
  for (int i = 0; i < adj[1].size(); i++) {
    cnt = 0;
    dfs(adj[1][i], 1, 0);
    sort(v, v + cnt);
    int mxm = v[0];
    for (int j = 1; j < cnt; j++) {
      if (v[j] <= v[j - 1]) v[j] = v[j - 1] + 1;
      mxm = max(mxm, v[j]);
    }
    res = max(res, mxm + 1);
  }
  cout << res << endl;
  return 0;
}
