The city consists of intersections connected by streets. After heavy snow, the mayor Milan orders the winter service to clear a chosen set of streets. The chosen streets are as few as possible while still keeping every two intersections connected by exactly one path, so they form a tree over the $N$ intersections.
The winter service has two snow plows, driven by Mirko and Slavko. Both plows begin at the same intersection $S$.
A plow burns one liter of fuel per meter it drives, even when it passes along a street that is already clear. Together, the two plows must clear every chosen street at least once. Each plow follows one route that starts at $S$; when all streets are clear, each plow parks at the last intersection it reached. Mirko and Slavko need not finish at the same intersection.
Compute the minimum total amount of fuel the two plows spend.
The first line contains two integers $N$ and $S$ ($1 \le N \le 100,000$, $1 \le S \le N$): the number of intersections and the starting intersection. Intersections are numbered from $1$ to $N$.
Each of the next $N-1$ lines contains three integers $A$, $B$, and $C$ ($1 \le C \le 1000$), meaning that a street of length $C$ meters directly connects intersections $A$ and $B$.
Print a single integer: the minimum total fuel needed to clear all streets.