#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10, mod = 1e9 + 7;
const long long infl = LLONG_MAX / 2;
int n, ans, h[N];
vector<int> g[N], L;
void dfs(int u = 0, int p = -1) {
  bool leaf = 1;
  for (int x : g[u])
    if (x - p) {
      h[x] = h[u] + 1;
      dfs(x, u);
      leaf = 0;
    }
  if (leaf) L.push_back(h[u]);
  if (h[u] == 1) {
    sort(L.begin(), L.end());
    int now = 0;
    for (int i = 0; i < L.size(); ++i) {
      now = max(now + 1, L[i]);
    }
    ans = max(ans, now - 1);
    L.clear();
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    --u;
    --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs();
  cout << ans + 1;
}
