#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int n, ans;
vector<int> adj[N], e;
void dfs(int u, int p, int d) {
  for (int v : adj[u]) {
    if (v ^ p) dfs(v, u, d + 1);
  }
  if (adj[u].size() == 1) e.emplace_back(d);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].emplace_back(v);
    adj[v].emplace_back(u);
  }
  for (int v : adj[1]) {
    dfs(v, 1, 1);
    sort(e.begin(), e.end());
    for (int i = 1; i < e.size(); ++i) {
      e[i] = max(e[i - 1] + 1, e[i]);
    }
    ans = max(e[e.size() - 1], ans);
    e.clear();
  }
  cout << ans << endl;
  return 0;
}
