Sonya likes ice cream very much. She eats it even during programming competitions. That is why the girl decided that she wants to open her own ice cream shops.

Sonya lives in a city with n junctions and n-1 streets between them. All streets are two-way and connect two junctions. It is possible to travel from any junction to any other using one or more streets. City Hall allows opening shops only on junctions. The girl cannot open shops in the middle of streets. 

Sonya has exactly k friends whom she can trust. If she opens a shop, one of her friends has to work there and not to allow anybody to eat an ice cream not paying for it. Since Sonya does not want to skip an important competition, she will not work in shops personally.

Sonya wants all her ice cream shops to form a simple path of the length r (1 ≤ r ≤ k), i.e. to be located in different junctions f_1, f_2, ..., f_r and there is street between f_i and f_{i+1} for each i from 1 to r-1.

The girl takes care of potential buyers, so she also wants to minimize the maximum distance between the junctions to the nearest ice cream shop. The distance between two junctions a and b is equal to the sum of all the street lengths that you need to pass to get from the junction a to the junction b. So Sonya wants to minimize

$$$max_{a} min_{1 ≤ i ≤ r} d_{a,f_i}$$$

where a takes a value of all possible n junctions, f_i — the junction where the i-th Sonya's shop is located, and d_{x,y} — the distance between the junctions x and y.

Sonya is not sure that she can find the optimal shops locations, that is why she is asking you to help her to open not more than k shops that will form a simple path and the maximum distance between any junction and the nearest shop would be minimal. 

Input

The first line contains two integers n and k (1≤ k≤ n≤ 10^5) — the number of junctions and friends respectively.

Each of the next n-1 lines contains three integers u_i, v_i, and d_i (1≤ u_i, v_i≤ n, v_i≠ u_i, 1≤ d≤ 10^4) — junctions that are connected by a street and the length of this street. It is guaranteed that each pair of junctions is connected by at most one street. It is guaranteed that you can get from any junctions to any other.

Output

Print one number — the minimal possible maximum distance that you need to pass to get from any junction to the nearest ice cream shop. Sonya's shops must form a simple path and the number of shops must be at most k.

Examples

Input

6 2
1 2 3
2 3 4
4 5 2
4 6 3
2 4 6


Output

4


Input

10 3
1 2 5
5 7 2
3 2 6
10 6 3
3 8 1
6 4 2
4 1 6
6 9 4
5 2 5


Output

7

Note

In the first example, you can choose the path 2-4, so the answer will be 4.

<image> The first example.

In the second example, you can choose the path 4-1-2, so the answer will be 7.

<image> The second example.
#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5 + 100;
int head[mx], vis[mx], dis1[mx], dis2[mx], dp[mx], son[mx], in[mx];
int cnt = 0, n, k, a, b, c, pa, pb, mid;
struct Edge {
  int to, val, next;
} edge[mx << 2];
struct node {
  int id, len, fa;
  node() {}
  node(int pp, int ll, int ff) {
    id = pp;
    len = ll;
    fa = ff;
  }
  bool operator<(const node a) const { return len < a.len; }
};
void add(int a, int b, int v) {
  edge[cnt].to = b;
  edge[cnt].next = head[a];
  edge[cnt].val = v;
  head[a] = cnt++;
}
void init() {
  cnt = 0;
  memset(head, -1, sizeof(head));
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    son[i] = i;
    dp[i] = 0;
  }
}
void dfs(int x, int fa) {
  for (int i = head[x]; ~i; i = edge[i].next) {
    int nxt = edge[i].to;
    if (nxt == fa) continue;
    dfs(nxt, x);
    if (dp[nxt] + edge[i].val > dp[x]) {
      dp[x] = dp[nxt] + edge[i].val;
      son[x] = nxt;
    }
  }
}
int main() {
  init();
  scanf("%d%d", &n, &k);
  for (int i = 1; i < n; i++) {
    scanf("%d%d%d", &a, &b, &c);
    add(a, b, c);
    add(b, a, c);
  }
  int mmax = 0;
  queue<int> que;
  que.push(1);
  dis1[1] = 0;
  vis[1] = 1;
  while (!que.empty()) {
    int now = que.front();
    que.pop();
    for (int i = head[now]; ~i; i = edge[i].next) {
      int nxt = edge[i].to;
      if (vis[nxt]) continue;
      vis[nxt] = 1;
      dis1[nxt] = dis1[now] + edge[i].val;
      que.push(nxt);
      if (dis1[nxt] > mmax) {
        mmax = dis1[nxt];
        pa = nxt;
      }
    }
  }
  mmax = 0;
  dis2[pa] = 0;
  que.push(pa);
  memset(vis, 0, sizeof(vis));
  vis[pa] = 1;
  while (!que.empty()) {
    int now = que.front();
    que.pop();
    for (int i = head[now]; ~i; i = edge[i].next) {
      int nxt = edge[i].to;
      if (vis[nxt]) continue;
      vis[nxt] = 1;
      dis2[nxt] = dis2[now] + edge[i].val;
      que.push(nxt);
      if (dis2[nxt] > mmax) {
        mmax = dis2[nxt];
        pb = nxt;
      }
    }
  }
  mmax = 0;
  dis1[pb] = 0;
  que.push(pb);
  memset(vis, 0, sizeof(vis));
  vis[pb] = 1;
  while (!que.empty()) {
    int now = que.front();
    que.pop();
    for (int i = head[now]; ~i; i = edge[i].next) {
      int nxt = edge[i].to;
      if (vis[nxt]) continue;
      vis[nxt] = 1;
      dis1[nxt] = dis1[now] + edge[i].val;
      que.push(nxt);
    }
  }
  mmax = 2000000000;
  for (int i = 1; i <= n; i++)
    if (max(dis1[i], dis2[i]) < mmax) mmax = max(dis1[i], dis2[i]), mid = i;
  dfs(mid, mid);
  int cont = 1;
  mmax = 0;
  priority_queue<node> q;
  q.push(node(mid, dp[mid], mid));
  while (!q.empty()) {
    if (cont >= k) break;
    node now = q.top();
    if (now.fa != now.id) {
      if (in[now.id] >= 2 || in[now.fa] >= 2) break;
      in[now.id]++;
      in[now.fa]++;
      cont++;
      q.pop();
    } else
      q.pop();
    for (int i = head[now.id]; ~i; i = edge[i].next) {
      int nxt = edge[i].to;
      if (nxt == now.fa) continue;
      q.push(node(nxt, dp[nxt] + edge[i].val, now.id));
    }
  }
  if (q.empty())
    puts("0");
  else {
    node res = q.top();
    printf("%d\n", res.len);
  }
  return 0;
}
