#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e6 + 1;
const int INF = 1e9 + 7;
const int INFL = 1e18 + 7;
long long n, u, v, sz, ans, maxk, x;
vector<int> g[MXN], have;
void dfs(int v, int p, int l) {
  for (auto to : g[v]) {
    if (to != p) dfs(to, v, l + 1);
  }
  if (g[v].size() == 1) {
    have.push_back(l);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (auto to : g[1]) {
    have.clear();
    dfs(to, 1, 0);
    sort(have.begin(), have.end());
    maxk = -1;
    for (auto z : have) {
      if (z > maxk)
        maxk = z;
      else
        maxk++;
    }
    ans = max(ans, max(maxk, 0LL));
  }
  cout << ans + 1;
  return 0;
}
