#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:160777216")
long long MOD = 1000000007;
using namespace std;
int i, j, n, m;
int d[1000000];
vector<int> g[1000000];
int u[1000000];
vector<int> v;
void dfs(int x, int dep) {
  u[x] = 1;
  d[x] = dep;
  for (int i = 0; i < g[x].size(); i++) {
    if (!u[g[x][i]]) dfs(g[x][i], dep + 1);
  }
  if (g[x].size() == 1) v.push_back(dep);
}
int main() {
  cin >> n;
  for (i = 0; i < n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  u[1] = 1;
  int ans = 0;
  for (i = 0; i < g[1].size(); i++) {
    v.clear();
    dfs(g[1][i], 0);
    sort(v.begin(), v.end());
    int curtime = -1;
    for (j = 0; j < v.size(); j++) {
      if (v[j] > curtime) {
        curtime = v[j];
      } else
        curtime++;
    }
    ans = max(ans, curtime + 1);
  }
  cout << ans << endl;
  return 0;
}
