#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e18;
const int N = 5 * 1e5 + 10;
ll res, n;
ll a[N];
std::vector<ll> v[N], leafs;
void dfs(ll x, ll p, ll h) {
  if (v[x].size() == 1) leafs.push_back(h);
  for (auto i : v[x]) {
    if (i != p) {
      dfs(i, x, h + 1);
    }
  }
}
void solve() {
  cin >> n;
  ll x, y;
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  ll ans = 0;
  for (auto i : v[1]) {
    dfs(i, 1, 0);
    ll m = leafs.size();
    sort(leafs.begin(), leafs.end());
    for (int j = 1; j < m; j++) {
      if (leafs[j] <= leafs[j - 1]) leafs[j] = leafs[j - 1] + 1;
    }
    ans = max(ans, leafs[m - 1]);
    leafs.clear();
  }
  cout << ans + 1 << "\n";
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  while (t--) {
    solve();
  }
}
