#include <bits/stdc++.h>
using namespace std;
vector<int> adj[500010];
vector<int> z;
int n, u, v, ans;
void dfs(int actual, int prev, int dist) {
  bool child = true;
  for (int i = 0; i < adj[actual].size(); i++) {
    if (adj[actual][i] != prev) {
      child = false;
      dfs(adj[actual][i], actual, dist + 1);
    }
  }
  if (child) {
    z.push_back(dist);
  }
}
int solve(int actual, int prev) {
  z.clear();
  dfs(actual, prev, 0);
  sort(z.begin(), z.end());
  for (int i = 1; i < z.size(); i++) {
    z[i] = max(z[i - 1] + 1, z[i]);
  }
  return z.back();
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(20) << fixed;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 0; i < adj[1].size(); i++) {
    ans = max(ans, solve(adj[1][i], 1) + 1);
  }
  cout << ans << '\n';
  return 0;
}
