#include <bits/stdc++.h>
using namespace std;
int n, ans;
vector<int> G[500002];
vector<int> meh;
void dfs(int x, int p, int d) {
  if (G[x].size() == 1) {
    meh.push_back(d);
    return;
  }
  for (auto it : G[x])
    if (it != p) dfs(it, x, d + 1);
}
int solve(int x) {
  meh.clear();
  dfs(x, 1, 0);
  sort(meh.begin(), meh.end());
  for (int i = 1; i < meh.size(); i++) meh[i] = max(meh[i], meh[i - 1] + 1);
  return meh.back();
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for (int i = 0; i < G[1].size(); i++) ans = max(ans, solve(G[1][i]) + 1);
  cout << ans;
  return 0;
}
