Flowery Trails
In order to attract more visitors, the manager of a national park had the idea of planting flowers along both sides of the popular trails, which are the trails used by common people. Common people only go from the park entrance to its highest peak, where views are breathtaking, by a shortest path. So, he wants to know how many metres of flowers are needed to materialize his idea.
For instance, in the park whose map is depicted in the figure, common people make only one of the three following paths (which are the shortest paths from the entrance to the highest peak).
At the entrance, some start in the rightmost trail to reach the point of interest (after metres), follow directly to point metres) and then pick the direct trail to the highest peak ( metres).
The others go to the left at the entrance and reach point (after metres). Then, they take one of the two trails that lead to point (both have metres). At point , they follow the direct trail to the highest peak ( metres).
Notice that popular trails (i.e., the trails followed by common people) are highlighted in yellow. Since the sum of their lengths is metres, the extent of flowers needed to cover both sides of the popular trails is metres .
Given a description of the park, with its points of interest and (two-way) trails, the goal is to find out the extent of flowers needed to cover both sides of the popular trails. It is guaranteed that, for the given inputs, there is some path from the park entrance to the highest peak.
Input
The first line has two integers: and . is the number of points of interest and is the number of trails. Points are identified by integers, ranging from to . The entrance point is and the highest peak is point .
Each of the following lines characterises a different trail. It contains three integers, , and , which indicate that the (two-way) trail links directly points and (not necessarily distinct) and has length (in metres).
Output
The output has a single line with the extent of flowers (in metres) needed to cover both sides of the popular trails.