#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[500001];
map<long long, long long> lvs;
void dfs(long long x, long long p, long long ht) {
  if ((long long)adj[x].size() == 1) {
    lvs[ht]++;
    return;
  }
  for (auto ch : adj[x])
    if (ch != p) dfs(ch, x, ht + 1);
}
int32_t main() {
  long long i, j, lt, d, z, v, c, r, l, t1, k, h, n, u, m, q, ts, te, x, y;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  h = 0;
  for (auto ch : adj[1]) {
    lvs.clear();
    dfs(ch, 1, 1);
    k = 0;
    while (lvs.size()) {
      auto tm = *lvs.begin();
      x = tm.first;
      y = tm.second;
      lvs.erase(lvs.begin());
      if (y > 1) lvs[x + 1] += y - 1;
      k = x;
    }
    h = max(h, k);
  }
  cout << h;
}
