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;
inline long long getint() {
  long long _x = 0, _tmp = 1;
  char _tc = getchar();
  while ((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
  if (_tc == '-') _tc = getchar(), _tmp = -1;
  while (_tc >= '0' && _tc <= '9') _x *= 10, _x += (_tc - '0'), _tc = getchar();
  return _x * _tmp;
}
long long mypow(long long _a, long long _x, long long _mod) {
  if (_x == 0) return 1ll;
  long long _tmp = mypow(_a, _x / 2, _mod);
  _tmp = (_tmp * _tmp) % _mod;
  if (_x & 1) _tmp = (_tmp * _a) % _mod;
  return _tmp;
}
inline long long add(long long _x, long long _y,
                     long long _mod = 1000000007ll) {
  long long _ = _x + _y;
  if (_ >= _mod) _ -= _mod;
  return _;
}
inline long long sub(long long _x, long long _y,
                     long long _mod = 1000000007ll) {
  long long _ = _x - _y;
  if (_ < 0) _ += _mod;
  return _;
}
inline long long mul(long long _x, long long _y,
                     long long _mod = 1000000007ll) {
  long long _ = _x * _y;
  if (_ >= _mod) _ %= _mod;
  return _;
}
inline bool equal(double _x, double _y) {
  return _x > _y - 1e-9 && _x < _y + 1e-9;
}
int __ = 1, _cs;
int n;
vector<int> v[555555];
void build() {}
void init() {
  n = getint();
  for (int i = 1; i < n; i++) {
    int xi = getint();
    int yi = getint();
    v[xi].push_back(yi);
    v[yi].push_back(xi);
  }
}
vector<int> dep;
void DFS(int now, int prt, int tdep) {
  if ((int)v[now].size() == 1) {
    dep.push_back(tdep);
    return;
  }
  for (size_t i = 0; i < v[now].size(); i++)
    if (v[now][i] != prt) DFS(v[now][i], now, tdep + 1);
}
long long cal(int tn) {
  dep.clear();
  DFS(tn, 1, 0);
  sort((dep).begin(), (dep).end());
  for (size_t i = 1; i < dep.size(); i++) dep[i] = max(dep[i], dep[i - 1] + 1);
  return dep.back();
}
void solve() {
  long long ans = 0;
  for (size_t i = 0; i < v[1].size(); i++) ans = max(ans, cal(v[1][i]));
  cout << ans + 1 << endl;
}
int main() {
  build();
  while (__--) {
    init();
    solve();
  }
}
