#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
int n, v, u, ans;
vector<int> vec, g[N];
void dfs(int v, int p, int h) {
  for (int u : g[v])
    if (u != p) dfs(u, v, h + 1);
  if (g[v].size() == 1) vec.push_back(h);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i + 1 < n; i++) {
    cin >> v >> u;
    v--;
    u--;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  for (int u : g[0]) {
    dfs(u, 0, 0);
    sort(vec.begin(), vec.end());
    for (int i = 1; i < vec.size(); i++) vec[i] = max(vec[i], vec[i - 1] + 1);
    ans = max(ans, vec.back());
    vec.clear();
  }
  cout << ans + 1;
}
