#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T& num) {
  char CH;
  bool F = false;
  for (CH = getchar(); CH < '0' || CH > '9'; F = CH == '-', CH = getchar())
    ;
  for (num = 0; CH >= '0' && CH <= '9';
       num = num * 10 + CH - '0', CH = getchar())
    ;
  F && (num = -num);
}
int stk[70], tp;
template <class T>
inline void print(T p) {
  if (!p) {
    puts("0");
    return;
  }
  while (p) stk[++tp] = p % 10, p /= 10;
  while (tp) putchar(stk[tp--] + '0');
  putchar('\n');
}
const long long mod = 1e9 + 7;
const double PI = acos(-1.0);
const int inf = 1e9;
const int N = 5e5 + 10;
const int maxn = (1 << 20) + 14;
const double eps = 1e-12;
int n, cnt;
vector<int> ve[N];
int dep[N], num[N];
void dfs(int cur, int fa, int deep) {
  int len = ve[cur].size();
  for (int i = 0; i < len; i++) {
    int x = ve[cur][i];
    if (x == fa) continue;
    dfs(x, cur, deep + 1);
  }
  if (len == 1) dep[++cnt] = deep;
}
int main() {
  int u, v;
  read(n);
  for (int i = 1; i <= n - 1; i++) {
    read(u);
    read(v);
    ve[u].push_back(v);
    ve[v].push_back(u);
  }
  int len = ve[1].size(), ans = 0;
  for (int i = 0; i < len; i++) {
    cnt = 0;
    dfs(ve[1][i], 1, 1);
    sort(dep + 1, dep + cnt + 1);
    for (int j = 1; j <= cnt; j++) {
      num[j] = max(num[j - 1] + 1, dep[j]);
    }
    ans = max(ans, num[cnt]);
  }
  print(ans);
  return 0;
}
