Yudam and Woohyun are dating. Worried that Woohyun may be unfaithful, Yudam wants to monitor the places they often visit with CCTV cameras.
The connections between the places form a tree with vertices and edges. The distance between two vertices and is the number of edges on the unique simple path joining them.
Choose a nonnegative integer for every vertex .
- If , no CCTV camera is installed at vertex .
- If , a CCTV camera of range is installed at vertex . Its cost is , and it monitors every vertex whose distance from is at most .
Find the minimum possible total cost such that every vertex is monitored by at least one CCTV camera.
Input
The input is given from Standard Input in the following format:
For each (), there is an edge joining vertices and .
Output
Print the minimum total cost required to monitor every vertex.
Constraints
- .
- ().
- ().
- The given edges form a tree.
Subtasks
Samples
A CCTV camera of range at vertex monitors every vertex.
One valid placement uses range- CCTV cameras at vertices and .
For example, a CCTV camera of range at vertex monitors every vertex.