Tree is a connected graph without cycles. A leaf of a tree is any vertex connected with exactly one other vertex.

You are given a tree with n vertices and a root in the vertex 1. There is an ant in each leaf of the tree. In one second some ants can simultaneously go to the parent vertex from the vertex they were in. No two ants can be in the same vertex simultaneously except for the root of the tree.

Find the minimal time required for all ants to be in the root of the tree. Note that at start the ants are only in the leaves of the tree.

Input

The first line contains integer n (2 ≤ n ≤ 5·105) — the number of vertices in the tree.

Each of the next n - 1 lines contains two integers xi, yi (1 ≤ xi, yi ≤ n) — the ends of the i-th edge. It is guaranteed that you are given the correct undirected tree.

Output

Print the only integer t — the minimal time required for all ants to be in the root of the tree.

Examples

Input

12
1 2
1 3
1 4
2 5
2 6
3 7
3 8
3 9
8 10
8 11
8 12


Output

6


Input

2
2 1


Output

1
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("trapv")
long long power(long long x, long long y) {
  if (y == 0) {
    return 1;
  }
  long long p = power(x, y / 2);
  p = (p * p);
  return (y % 2 == 0) ? p : (x * p);
}
long long powm(long long x, long long y, long long m) {
  long long ans = 1, r = 1;
  x %= m;
  while (r > 0 && r <= y) {
    if (r & y) {
      ans *= x;
      ans %= m;
    }
    r <<= 1;
    x *= x;
    x %= m;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long lar = max(a, b);
  long long small = min(a, b);
  for (long long i = lar;; i += lar) {
    if (i % small == 0) {
      return i;
    }
  }
}
bool sortbysec(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.second < b.second);
}
bool sortbydec(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.first > b.first);
}
void dex(int a) {
  if (a == 1) {
    cout << "YES";
  }
  if (a == 2) {
    cout << "NO";
  }
  if (a == 3) {
    cout << "Yes";
  }
  if (a == 4) {
    cout << "No";
  }
}
void line(long long x) {
  for (long long i = 1; i <= x; i++) {
    cout << "-";
  }
  cout << '\n';
}
bool overflow(long double a, long double b) { return a * b > 1e18 + 10; }
long long mul(long long a, long long b, long long mod) {
  return ((a * 1LL * b) + mod) % mod;
}
long long sum(long long a, long long b, long long mod) { return (a + b) % mod; }
const long long N = (long long)(5e5 + 1);
const long long MOD = (long long)(1e9 + 7);
const long long INF = (long long)(2e18);
vector<long long> adj[N];
bool vis[N];
long long depth[N];
vector<long long> v;
void dfs(long long s, long long d) {
  vis[s] = true;
  depth[s] = d;
  long long leaf = 1;
  for (auto &it : adj[s]) {
    if (vis[it] == false) {
      leaf = 0;
      dfs(it, d + 1);
    }
  }
  if (leaf) {
    v.push_back(d);
  }
}
void solve(long long tc) {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n - 1; i++) {
    long long x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  vis[1] = true;
  long long ans = 0;
  for (auto &it : adj[1]) {
    v.clear();
    dfs(it, 1);
    long long n1 = (long long)v.size();
    long long cur = 0;
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    for (long long i = 0; i < n1; i++) {
      cur = max(cur, v[i] + i);
    }
    ans = max(cur, ans);
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long cnt = 1;
  long long t = 1;
  while (t--) {
    for (auto blockTime = make_pair(chrono::high_resolution_clock::now(), true);
         blockTime.second;
         fprintf(stderr, "%s: %lld ms\n", "solve",
                 chrono::duration_cast<chrono::milliseconds>(
                     chrono::high_resolution_clock::now() - blockTime.first)
                     .count()),
              fflush(stderr), blockTime.second = false) {
      solve(cnt);
    }
    cnt++;
  }
  return 0;
}
