#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int inf = 50000000;
const int maxn = 500010;
vector<int> adj[maxn];
void dfs(int cur, int parent, int d, vector<int> &v) {
  if (adj[cur].size() == 1) v.push_back(d);
  for (int it : adj[cur]) {
    if (it != parent) {
      dfs(it, cur, d + 1, v);
    }
  }
}
int solve(int cur) {
  vector<int> v;
  for (int it : adj[cur]) {
    if (it != 1) dfs(it, cur, 1, v);
  }
  sort(v.begin(), v.end());
  int ret = 0;
  for (int it : v) ret = max(it, ret + 1);
  return ret;
}
int main() {
  int n, i, u, v;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int ans = 0;
  for (int it : adj[1]) ans = max(ans, solve(it));
  printf("%d\n", ans + 1);
  return 0;
}
