Flowery Trails#7913

Flowery Trails

1 second
128 megabytes
Medium

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).

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 (3860 = 2 \cdot 1930).

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: p~(2 \le p \le 10000) and t~(1 \le t \le 250000). is the number of points of interest and is the number of trails. Points are identified by integers, ranging from to p - 1. The entrance point is and the highest peak is point p - 1.

Each of the following lines characterises a different trail. It contains three integers, p_1, p_2, and l~(1 \le l \le 1000), which indicate that the (two-way) trail links directly points p_1 and p_2 (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.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading