K. Kingdom Compression

Time limit: 0.3sMemory limit: 256MBInput: Output:

In the kingdom of Arbolia, nn cities are connected by roads. There is exactly one simple route between any two cities, so the road network forms a tree.

Mira wants to compress this network into a single super-city. She may repeatedly merge any two distinct cities into one new city, even if they are not directly connected by a road.

During this process, every pair of remaining cities has one of three possible relationships:

  • a black edge,
  • a red edge, or
  • no edge.

Initially, every road is a black edge, all other pairs have no edge, and there are no red edges.

Suppose Mira merges cities uu and vv into a new city ww. For each other remaining city xx, the relationship between ww and xx is determined as follows:

  • If at least one of the relationships (u,x)(u,x) or (v,x)(v,x) is a red edge, (w,x)(w,x) becomes a red edge.
  • Otherwise, if both relationships are black edges, (w,x)(w,x) is a black edge.
  • Otherwise, if both relationships have no edge, (w,x)(w,x) has no edge.
  • In all other cases, (w,x)(w,x) becomes a red edge.

The two old cities and all their relationships disappear after the merge.

The red degree of a city is the number of red edges incident to it. Mira wants to merge all cities into one while keeping the red degree of every city, at every moment, as small as possible.

Find the smallest integer dd for which Mira can perform all merges without any city ever having red degree greater than dd.

Input

The first line contains a single integer nn (1≤n≤1051 \le n \le 10^5) --- the number of cities.

Each of the next n−1n-1 lines contains two integers uu and vv (1≤u,v≤n1 \le u,v \le n, u≠vu \ne v), describing a road between cities uu and vv.

It is guaranteed that the given roads form a tree.

Output

Print a single integer: the minimum possible value of dd.

Example

stdin

4
4 3
2 1
4 2

stdout

1

Note

In the first example, there are 44 cities connected by 33 roads: (4,3)(4,3), (2,1)(2,1), and (4,2)(4,2). These roads form the path 1−2−4−31 - 2 - 4 - 3.

The answer is 11, meaning that it is possible to merge all cities into a single city while ensuring that, at every moment, each remaining city has at most one incident red edge.

However, it is impossible to complete the process without creating any red edges. Therefore, the minimum possible value of dd is 11.

Log In or Sign Up to be able to send submissions!