#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
long long MAX = 1e17;
vector<vector<int> > g(5000010);
int d[5000010];
int main() {
  ios_base::sync_with_stdio(0);
  ;
  int n;
  cin >> n;
  vector<int> v;
  int num = 0;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
    if (x == 1)
      v.push_back(y);
    else if (y == 1)
      v.push_back(x);
  }
  for (int i = 1; i < n + 1; i++) d[i] = -1;
  d[1] = 0;
  int ans = 0;
  for (auto it = v.begin(); it != v.end(); it++) {
    vector<int> depth;
    if (g[*it].size() == 1)
      depth.push_back(0);
    else {
      queue<int> q;
      q.push(*it);
      d[*it] = 0;
      while (!q.empty()) {
        int k = q.front();
        q.pop();
        for (auto iter = g[k].begin(); iter != g[k].end(); iter++) {
          if (d[*iter] >= 0) continue;
          d[*iter] = d[k] + 1;
          if (g[*iter].size() == 1) {
            depth.push_back(d[*iter]);
            continue;
          }
          q.push(*iter);
        }
      }
    }
    sort(depth.begin(), depth.end());
    int t = -1;
    for (auto iter = depth.begin(); iter != depth.end(); iter++) {
      t = max(t + 1, *iter);
    }
    ans = max(ans, t + 1);
  }
  cout << ans << endl;
}
