#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
vector<int> g[N];
int n;
void dfs(int v, int p, int dep, vector<int>& leaves) {
  if (p == 0 && g[v].size() == 1) leaves.push_back(dep);
  for (int to : g[v]) {
    if (to != p) {
      if (g[to].size() == 1) leaves.push_back(dep + 1);
      dfs(to, v, dep + 1, leaves);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vector<int> curr;
  int ans = 0;
  for (int v : g[0]) {
    curr.clear();
    dfs(v, 0, 0, curr);
    sort(curr.begin(), curr.end());
    int prev = curr[0];
    ans = max(ans, prev);
    for (int i = 1; i < curr.size(); ++i) {
      prev = max(curr[i], prev + 1);
      ans = max(ans, prev);
    }
  }
  cout << ans + 1 << endl;
  return 0;
}
