#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 123;
int n;
vector<int> G[N], z;
void dfs(int i = 1, int p = 0, int depth = 0) {
  bool used = 0;
  for (int j = 0; j < G[i].size(); j++)
    if (G[i][j] != p) {
      used = 1;
      dfs(G[i][j], i, depth + 1);
    }
  if (!used) z.push_back(depth);
}
int main() {
  cin >> n;
  for (int x, y, i = 0; i < n - 1; i++) {
    cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  int ans = 0;
  for (int i = 0; i < G[1].size(); i++) {
    dfs(G[1][i], 1, 1);
    sort(begin(z), end(z));
    int mx = z[0];
    for (int j = 1; j < z.size(); j++) mx = max(mx + 1, z[j]);
    ans = max(ans, mx);
    z.clear();
  }
  cout << ans;
}
