#include <bits/stdc++.h>
#pragma optimise GCC(-O2)
using namespace std;
mt19937_64 rang(
    chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
long long INF = LLONG_MAX;
const long long M = 1000000007;
long long powm(long long, long long);
vector<vector<long long> > g;
vector<vector<long long> > dis;
vector<bool> vis;
void bfs(long long n, long long dist, int origin) {
  queue<pair<long long, long long> > q;
  q.push({n, dist});
  vis[n] = 1;
  while (!q.empty()) {
    auto pr = q.front();
    q.pop();
    bool leaf = 1;
    for (auto x : g[pr.first]) {
      if (!vis[x]) {
        vis[x] = 1;
        leaf = 0;
        q.push({x, pr.second + 1});
      }
    }
    if (leaf) {
      dis[n].push_back(pr.second);
    }
  }
}
long long fella(long long x) {
  long long highest = dis[x][0];
  for (int i = 1; i < dis[x].size(); i++) {
    long long val = dis[x][i];
    if (val > highest) {
      highest = val;
    } else
      highest++;
  }
  return highest;
}
long long solve() {
  long long ans = 0;
  vis[0] = 1;
  for (auto x : g[0]) {
    bfs(x, 0, x);
    sort(dis[x].begin(), dis[x].end());
    ans = max(ans, fella(x));
  }
  return ans + 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  g.resize(n);
  vis.resize(n + 1, 0);
  dis.resize(n);
  for (int i = 0; i < n - 1; i++) {
    long long x;
    cin >> x;
    long long y;
    cin >> y;
    x--, y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  cout << solve();
}
long long powm(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % M;
    a = (a * a) % M;
    b >>= 1;
  }
  return res;
}
