#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > adj;
set<int> av;
stack<int> taken;
int n, mx = 0;
void f(int i, int p, int t) {
  bool lv = 1;
  for (int v : adj[i]) {
    if (v == p) continue;
    lv = 0;
    f(v, i, t + 1);
  }
  if (lv) {
    auto it = av.lower_bound(t);
    mx = max(mx, *it);
    taken.push(*it);
    av.erase(it);
  }
  if (t == 1)
    while (!taken.empty()) av.insert(taken.top()), taken.pop();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  adj = vector<vector<int> >(n);
  for (int((i)) = (0); ((i)) < ((n - 1)); ((i))++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (int((i)) = (0); ((i)) < ((2 * n)); ((i))++) av.insert(i);
  f(0, -1, 0);
  cout << mx << endl;
}
