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 long long MAXN = 200001;
struct edge {
  long long u, v, w;
} e[MAXN * 2];
long long dist[MAXN], mx, node, x, y, n, m, k;
vector<pair<long long, long long> > tree[MAXN];
pair<long long, long long> info[MAXN];
long long color[MAXN], d[MAXN], par[MAXN];
void getCenter(long long here, long long dad, long long dep) {
  par[here] = dad;
  if (dep > mx) {
    mx = dep;
    node = here;
  }
  dist[here] = max(dist[here], dep);
  for (long long i = 0; i < tree[here].size(); i++) {
    long long there = tree[here][i].first;
    long long w = tree[here][i].second;
    if (there == dad) continue;
    getCenter(there, here, dep + w);
  }
}
void dfs1(int here, int dad) {
  for (int i = 0; i < tree[here].size(); i++) {
    int there = tree[here][i].first;
    int w = tree[here][i].second;
    if (there == dad) continue;
    dfs1(there, here);
    d[here] = max(d[there] + w, d[here]);
  }
}
int id = 0;
long long mmax[MAXN], cnt;
long long cen = 1;
int chk[MAXN];
void dfs(int here, int dad, int bound) {
  int t = 0;
  chk[cen] = 1;
  for (int i = 0; i < tree[here].size(); i++) {
    int there = tree[here][i].first;
    int w = tree[here][i].second;
    if (there == dad) continue;
    if (d[there] + w > bound) {
      chk[there] = 1;
      cnt++;
      dfs(there, here, bound);
    }
  }
}
int ok(int bound) {
  cnt = 0;
  memset(chk, 0, sizeof(chk));
  dfs(cen, -1, bound);
  int good = 1;
  for (int i = 1; i <= n; i++) {
    int t = 0;
    for (int j = 0; j < tree[i].size(); j++) {
      int x = tree[i][j].first;
      t += chk[x];
    }
    good &= (t <= 2);
  }
  good &= (cnt < k);
  return good;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (long long i = 1; i <= n - 1; i++) {
    cin >> e[i].u >> e[i].v >> e[i].w;
    tree[e[i].u].push_back({e[i].v, e[i].w});
    tree[e[i].v].push_back({e[i].u, e[i].w});
  }
  long long dia = 0;
  mx = 0;
  node = 0;
  getCenter(1, -1, 0);
  mx = 0;
  x = node;
  getCenter(x, -1, 0);
  dia = mx;
  y = node;
  memset(dist, 0, sizeof(dist));
  getCenter(x, -1, 0);
  getCenter(y, -1, 0);
  long long radius = 1e18;
  for (long long i = 1; i <= n; i++) {
    if (radius > dist[i]) {
      radius = dist[i];
      cen = i;
    }
  }
  memset(dist, 0, sizeof(dist));
  dfs1(cen, -1);
  int lo = 0;
  int hi = dia;
  while (lo <= hi) {
    int mid = (lo + hi) / 2;
    if (ok(mid))
      hi = mid - 1;
    else
      lo = mid + 1;
  }
  cout << hi + 1;
  return 0;
}
