#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> lista[500002];
int padre[500002];
int ans(int nodo) {
  vector<int> arr;
  int d = 0;
  queue<int> cola;
  cola.push(nodo);
  while (!cola.empty()) {
    for (int i = cola.size(); i; i--) {
      nodo = cola.front();
      cola.pop();
      if (lista[nodo].size() == 1) arr.push_back(d);
      for (int i = 0; i < lista[nodo].size(); i++) {
        if (lista[nodo][i] != padre[nodo]) {
          padre[lista[nodo][i]] = nodo;
          cola.push(lista[nodo][i]);
        }
      }
    }
    d++;
  }
  int tMax = -1;
  for (int i = 0; i < arr.size(); i++) tMax = max(arr[i], tMax + 1);
  return tMax;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  int a, b;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    lista[a].push_back(b);
    lista[b].push_back(a);
  }
  int r = -1;
  for (int i = 0; i < lista[1].size(); i++) {
    padre[lista[1][i]] = 1;
    r = max(r, ans(lista[1][i]));
  }
  cout << r + 1 << "\n";
  return 0;
}
