You are given a tree with vertices, numbered from to (a tree is an undirected connected graph in which there are no cycles).
You are asked to partition it into edge-disjoint simple paths such that the length of the shortest one is maximized.
In this task, the length of a path is defined as the number of edges it has.
Input data
The first line contains an integer . The next lines contain integers , denoting an edge of the tree.
Output data
You need to write a single line with an integer: the maximum length of the shortest path over all partitions of the tree into edge-disjoint simple paths.
Constraints and clarifications
- .
- .
- For tests worth points, .
- For tests worth more points, .
- For tests worth more points, .
Example 1
stdin
9
9 8
7 4
7 8
2 1
6 3
5 1
5 8
3 8
stdout
4
Explanation
In the first sample case, an optimal split would be into edge-disjoint paths, each of length : and .
Example 2
stdin
5
1 2
2 3
3 4
2 5
stdout
2
Explanation
In the second sample case, an optimal split would be into edge-disjoint paths, each of length : and .
Example 3
stdin
10
7 6
9 6
8 5
4 2
1 3
5 6
1 10
7 10
2 6
stdout
4
Explanation
In the third sample case, an optimal split would be into edge-disjoint paths, one of length : and the other one of length : .
Example 4
stdin
6
1 2
2 3
3 4
4 5
5 6
stdout
5
Explanation
In the fourth sample case, the whole tree consists of only one path of length .