Given an undirected tree with n vertices. Each edge x has a cost wx. The root of the tree is 1.
You have m robots, each robot starts at root, walks through edges, finally stops at any vertex. When a robot travels through an edge x, you will pay wx.
You need to make each edge to be visited by at least one robot (can be more than one robot).
Your goal is minimize the cost.
Input
The first line contains two integers, n and m.
In the next n−1 lines, each line contains three integers, ui,vi,wi, means an edge (ui,vi) exists, and the cost is wi.
It's guaranteed that the given graph is a tree.
Output
An integer representing the minimum cost.
Constraints
1≤n≤5⋅104
1≤m≤50
1≤ui,vi≤n
1≤wi≤109
The first robot's route is 1−2−3−5−3−4, and the rest two stay at root.