#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > v;
vector<int> child;
int n, res;
void dfs(int x, int u, int d) {
  if (v[x].size() == 1) {
    child.push_back(d);
    return;
  }
  for (int i = 0; i < v[x].size(); i++)
    if (v[x][i] != u) dfs(v[x][i], x, d + 1);
}
int prod(int u) {
  child.clear();
  dfs(u, 0, 0);
  sort(child.begin(), child.end());
  for (int i = 1; i < child.size(); i++) {
    if (child[i - 1] >= child[i]) child[i] = child[i - 1] + 1;
  }
  return child[child.size() - 1];
}
int main() {
  scanf("%d", &n);
  v.resize(n + 1);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--, y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (int i = 0; i < v[0].size(); i++) res = max(res, prod(v[0][i]));
  cout << res + 1 << endl;
}
