#include <bits/stdc++.h>
#pragma comment(linker, "/stack:16777216")
using namespace std;
const int INF = 1000000000;
const int BASE = 1000000007;
const int MAX = 500007;
const int MAX2 = 7777;
const int MAXE = 100000;
const int ADD = 1000000;
const int MOD = 1000000007;
const int CNT = 800;
const int MAGIC = 400;
vector<int> G[MAX];
vector<int> c;
void dfs(int v, int p, int d) {
  if (G[v].size() == 1) {
    c.push_back(d);
  }
  for (int i = (0); i < (G[v].size()); i++) {
    int to = G[v][i];
    if (to == p) continue;
    dfs(to, v, d + 1);
  }
}
int solve() {
  sort(c.begin(), c.end());
  int res = 0;
  for (int i = (0); i < (c.size()); i++) {
    res = max(res, c[i]) + 1;
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  for (int i = (0); i < (n - 1); i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int res = 0;
  for (int i = (0); i < (G[0].size()); i++) {
    c.clear();
    dfs(G[0][i], 0, 0);
    res = max(res, solve());
  }
  cout << res << endl;
  return 0;
}
