#include <bits/stdc++.h>
using namespace std;
vector<long long int> a[500005], v[500005];
long long n, cnt;
void dfs(long long node, long long p, long long d) {
  if (a[node].size() == 1) v[cnt].push_back(d);
  for (auto i : a[node])
    if (i != p) dfs(i, node, d + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long i, j;
  cin >> n;
  for (i = 1; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  for (auto i : a[1]) {
    if (a[i].size() == 1) continue;
    dfs(i, 1, 0);
    sort((v[cnt]).begin(), (v[cnt]).end());
    cnt++;
  }
  long long ans = 0, cur = 0;
  for (i = 0; i < cnt; i++) {
    cur = 0;
    for (auto j : v[i]) {
      if (j != 0) cur++;
      cur = max(cur, j);
    }
    ans = max(ans, cur);
  }
  cout << ans + 1;
  return 0;
}
