Xonya and graph
The Xonya's city consists of crossroads connected by two-way roads.
The crossroads are numbered from to . The roads are also numbered from to . The -th road connects the intersection with the intersection and has length .
It is known that from each intersection it is possible to get to each other using roads. There is at most one road between every two intersections. There is no road leading from the intersection to it.
Let's the distance be the length of the shortest path between the intersections and .
Xonya wants to find two intersections in the city such that is maximum among all possible .
Input
The first line contains two integers and (, ) — the number of intersections in the city and the group number respectively.
Each of the next lines contains three integers (, ).
It is guaranteed that from each intersection you can get to each other using roads.
It is guaranteed that there is no road from the intersection to it.
It is guaranteed that there is at most one road between two intersections.
Output
Print the largest value of over all pairs of intersections .
Examples
Note
Notes to the first sample.
So, the maximum is .
Scoring
( points): graph has the form of one cycle.
( points): .
( points): the length of each cycle in the graph is no more than 1000.
( points): .
( points): no additional restrictions.