#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int from, to;
  vector<vector<int>> edges(n);
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d%d", &from, &to);
    --from;
    --to;
    edges[from].push_back(to);
    edges[to].push_back(from);
  }
  queue<int> q;
  vector<int> depth(n);
  vector<int> parent(n, -2);
  vector<char> vacant(n, false);
  vector<vector<int>> z(n);
  q.push(0);
  parent[0] = -1;
  depth[0] = 0;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int node : edges[v]) {
      if (parent[node] == -2) {
        vacant[v] = true;
        depth[node] = depth[v] + 1;
        if (v == 0) {
          parent[node] = 0;
        } else if (parent[v] == 0) {
          parent[node] = v;
        } else {
          parent[node] = parent[v];
        }
        q.push(node);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (!vacant[i]) {
      z[parent[i]].push_back(depth[i] - 1);
    }
  }
  for (int i = 0; i < z.size(); ++i) {
    sort(z[i].begin(), z[i].end());
  }
  int ticks = 0;
  for (int i = 1; i < z.size(); ++i) {
    int a = -1;
    for (int j = 0; j < z[i].size(); ++j) {
      a = max(z[i][j], a + 1);
    }
    ticks = max(ticks, a);
  }
  printf("%d", ticks + 1);
  return 0;
}
