Junoh is top talent!!

In a weighted tree, find a simple path with the maximum number of nodes, then among those pick the one with the smallest total edge weight, and report that weight divided by T rounded up.

Medium7TreeDFSDynamic programmingGreedyNo attempts yetTime limit2sMemory limit512 MB

Problem

Junoh got an assignment from his mentor. The problem solving system used in the assignment works like this.

  1. There are NN problems and N1N-1 links, and each link joins two different problems. A link works in both directions.
  2. Starting from any problem, you reach every other problem by following links.
  3. For any two problems AA and BB, exactly one route leads from AA to BB.

Junoh picks any one of the NN problems and starts the test there. The first problem he picks counts as a bonus and is solved in 0 seconds. After solving a problem he chooses one of the links attached to it and moves to the problem on the other end. Passing a link costs the time written on that link, and the time to solve BB after AA equals the time to solve AA after BB. He can never go back to a problem he has already passed.

Junoh wants to solve as many problems as this system allows. He can spend TT time on solving problems each day, and when a day's time runs out he continues the rest on the next day. The work may be cut at a day boundary. So if the link times along the chosen route add up to SS, the number of days is SS divided by TT, rounded up. For example, with T=4T = 4 and a route whose link times are 3, 3, 3, the sum is 9, so the work splits into 4 + 4 + 1 and takes three days.

If several routes pass the maximum number of problems, Junoh takes the one that needs the fewest days. Given NN, TT and the links, compute the number of days.

Input

The first line contains the number of problems NN and the daily solving time TT (2N500002 \le N \le 50000, 1T1000001 \le T \le 100000). Each of the next N1N-1 lines contains three integers AA, BB, CC (1A,BN1 \le A, B \le N, 1C10001 \le C \le 1000). AA and BB are the numbers of the two problems joined by a link, and CC is the time it takes to solve BB after AA, or AA after BB.

Output

Print the smallest number of days Junoh needs to solve as many problems as possible.