#include <bits/stdc++.h>
using namespace std;
vector<int> adj[1000001];
bool vis[1000001];
vector<int> level;
void dfs(int start, int l) {
  bool atleastOne = false;
  vis[start] = true;
  for (auto child : adj[start]) {
    if (!vis[child]) {
      atleastOne = true;
      dfs(child, l + 1);
    }
  }
  if (atleastOne == false) {
    level.push_back(l);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  ;
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  int maxi = 0;
  vis[1] = true;
  for (auto child : adj[1]) {
    level.clear();
    dfs(child, 0);
    sort(level.begin(), level.end());
    for (int i = 1; i < level.size(); i++) {
      level[i] = max(level[i - 1] + 1, level[i]);
    };
    maxi = max(level[level.size() - 1], maxi);
  }
  cout << maxi + 1 << endl;
  return 0;
}
