#include <bits/stdc++.h>
using namespace std;
vector<int> adj[500009];
int N;
int buf[500009];
int total;
void dfs(int n, int p, int d) {
  if (adj[n].size() == 1) buf[total++] = d;
  for (int to : adj[n])
    if (to != p) dfs(to, n, d + 1);
}
int solve(int n) {
  total = 0;
  dfs(n, 1, 1);
  sort(buf, buf + total);
  int ret = 0;
  for (int i = 0; i < total; i++)
    if (ret < buf[i])
      ret = buf[i];
    else
      ret++;
  return ret;
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i < N; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  int ans = 0;
  for (int to : adj[1]) ans = max(ans, solve(to));
  printf("%d\n", ans);
  return 0;
}
