#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
int fans, n, h[maxn];
vector<int> adj[maxn], vec;
void dfs(int v, int p) {
  for (int u : adj[v])
    if (u != p) h[u] = h[v] + 1, dfs(u, v);
  if (h[v] != 0 && adj[v].size() == 1) vec.push_back(h[v]);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 1, u, v; i < n; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int v : adj[1]) {
    vec.clear();
    dfs(v, 1);
    sort(vec.begin(), vec.end());
    int ans = 0;
    if (vec.size()) ans = vec[0] - 1;
    for (int x : vec) ans = max(ans + 1, x);
    fans = max(ans, fans);
  }
  cout << fans + 1 << endl;
}
