At the beginning of the year 2026, the entire planet was infected by multiple viruses. In each country, a unique virus appeared. Due to the economic crisis that came along with these pandemics, international travel was restricted such that there exists a single route between any two distinct countries.
World leaders agreed that each day only one road among the remaining ones would be available for traversal. When a route between two countries is opened, the people of the two states infect each other, and the virus chosen by the leaders between the two remains alive in both states.
World leaders hired you to determine the minimum number of days needed for the entire planet to be infected by a single virus.
Task
Formally, you are given the list of edges of a tree with nodes. Initially, state is considered to be infected with the virus . On day , the edge modulo (let it be ) will be available and we are forced to perform one of the following two operations:
- (node receives the value of node )
- (node receives the value of node )
Edges and days are indexed starting from .
You are asked to output the minimum number of days after which it is guaranteed that all nodes will have the same value, assuming you apply an optimal strategy.
Input Data
On the first line, a single natural number is read, representing the number of nodes in the tree.
On the next lines, the edges that form the tree are read. On each line there are two distinct natural numbers between and , representing the endpoints of the respective edge.
Output Data
You must output a single natural number representing the minimum number of days required to infect the entire planet with the same virus.
Constraints
| # | Points | Restrictions |
|---|---|---|
| 1 | 30 | |
| 2 | 70 | No additional constraints |
Example 1
stdin
4
1 3
2 4
2 3
stdout
4
Explanation
In the first example, the tree is a chain of the form -- -- -- . On day , the edge -- will be available and we will choose to receive the value of . On day , the edge -- will be available and we will choose to receive the value of . On day , we will choose to receive the value of , and on day we will choose to receive the value of . After four days, all nodes will have the same value. It can be shown that the nodes cannot obtain the same value in fewer than four days.
After each step, the array looks as follows:
- (initial)
Example 2
stdin
10
10 6
7 5
5 8
1 6
4 3
1 4
3 9
8 6
2 8
stdout
20
* Gomory and Hu would have solved this problem, but at the moment they are very busy securing the APT network.