#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
const long long inf = 1e17;
const int mod = 1e9 + 7;
vector<int> edge[maxn];
bool mark[maxn];
int h[maxn];
vector<int> ant;
void dfs(int v) {
  mark[v] = true;
  if (edge[v].size() == 1) ant.push_back(h[v]);
  for (int u : edge[v]) {
    if (mark[u]) continue;
    h[u] = h[v] + 1;
    dfs(u);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int v, u;
    cin >> v >> u;
    v--;
    u--;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  mark[0] = true;
  int ans = 0;
  for (int u : edge[0]) {
    ant.clear();
    dfs(u);
    int l = -1;
    sort(ant.begin(), ant.end());
    for (int i : ant) {
      ans = max(ans, max(l + 1, i));
      l = max(l + 1, i);
    }
  }
  cout << ans + 1 << endl;
}
