#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using pii = pair<int, int>;
const double PI = 2 * asin(1);
int g_n;
vector<bool> vb;
vector<int> vi_num;
vector<vector<int>> vvi_e;
void pretreat() {}
void input() {
  vb.clear(), vb.resize(g_n + 1);
  vvi_e.clear(), vvi_e.resize(g_n + 1);
  for (int i = 1, u, v; i < g_n; ++i) {
    scanf(" %d %d", &u, &v);
    if (u > v) swap(u, v);
    if (u != 1) vvi_e[v].push_back(u);
    vvi_e[u].push_back(v);
  }
}
void dfs(int u, int dep) {
  vb[u] = true;
  int cnt = 0;
  for (int i = 0; i < vvi_e[u].size(); ++i) {
    int v = vvi_e[u][i];
    if (vb[v]) continue;
    ++cnt;
    dfs(v, dep + 1);
  }
  if (!cnt) {
    vi_num.push_back(dep);
  }
}
void solve() {
  int mx = 1;
  for (int i = 0; i < vvi_e[1].size(); ++i) {
    int u = vvi_e[1][i];
    if (vvi_e[u].size() > 0) {
      vi_num.clear();
      vb.clear(), vb.resize(g_n + 1);
      dfs(u, 1);
      sort(vi_num.begin(), vi_num.end());
      int tm = vi_num.front();
      for (int i = 1; i < vi_num.size(); ++i) {
        tm = max(tm + 1, vi_num[i]);
      }
      mx = max(mx, tm);
    }
  }
  cout << mx << endl;
}
int main() {
  pretreat();
  int t;
  while (cin >> g_n) {
    input();
    solve();
  }
  return 0;
}
