Problem Statement
You are given a tree with nodes labelled to and is rooted at node . For we define to be the size (number of nodes) of the subtree rooted at . You are to perform the following operation:
- Pick a node such that one of its children have the property
- Change the parent of either or to be any where and such that the tree remains a tree.
After performing any number of operations, determine the smallest length you can make the diameter.
Recall the definition of a tree is a connected graph with no cycles. Recall the diameter of the tree is defined to be the largest distance between any two nodes in the tree, and the distance between two nodes in a tree is the number of edges on the (only) path between those two nodes.
Input Format
Your first line will contain , the number of nodes. Your next lines will contain two space-separated integers each, and , meaning there is an edge between and .
Output Format
Output a single integer representing the smallest length you can make the diameter.
Constraints
Sample Cases
Input 1
7
1 2
1 3
2 4
2 5
4 6
4 7
Output 1
2
Input 2
5
1 2
1 3
3 4
3 5
Output 2
3
Input 3
10
1 2
1 3
1 4
1 5
1 6
1 7
7 8
7 9
7 10
Output 3
3
Comments