#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int nmax = 500005;
const long long inf = 1e9;
const double eps = 1e-6;
int leaf[nmax];
vector<vector<int> > g;
multiset<pair<int, int> > c[nmax];
int used[nmax];
int t[nmax];
void dfs(int v, int h) {
  used[v] = 1;
  int ws = 0;
  for (int j = 0; j < g[v].size(); ++j) {
    int to = g[v][j];
    if (!used[to]) {
      ws = 1;
      dfs(to, h + 1);
      if (!h) continue;
      if (c[v].size() < c[to].size()) {
        swap(c[to], c[v]);
      }
      for (multiset<pair<int, int> >::iterator it = c[to].begin();
           it != c[to].end(); ++it) {
        c[v].insert(*it);
      }
    }
  }
  if (!ws) {
    c[v].insert({1, h - 1});
    leaf[v] = 1;
  }
  if (h == 1) {
    while (!c[v].empty()) {
      pair<int, int> cur = *c[v].begin();
      c[v].erase(c[v].begin());
      if (!c[v].empty()) {
        pair<int, int> ls = *c[v].begin();
        c[v].erase(c[v].begin());
        ls.first = 0;
        ls.second = max(cur.second + 1, ls.second);
        c[v].insert(ls);
      } else {
        t[v] = cur.second;
        break;
      }
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  g.assign(n, vector<int>());
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0, 0);
  int ans = -1;
  for (int i = 0; i < g[0].size(); ++i) {
    ans = max(ans, t[g[0][i]]);
  }
  printf("%d\n", ans + 1);
  return 0;
}
