#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 5757;
const long long Linf = (long long)1e18 + 5757;
template <class T>
inline void umax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void umin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <class T>
inline T lcm(T a, T b) {
  return a / __gcd(a, b) * b;
}
inline int read() {
  int x;
  scanf(" %d", &x);
  return x;
}
const int N = 101010;
const int LG = 20;
int n, k;
vector<int> G[N];
int anc[N][LG + 1];
int tin[N], tout[N], ptr = 0;
int depth[N];
void dfs(int u, int p) {
  depth[u] = depth[p] + 1;
  anc[u][0] = p;
  for (int i = 1; i <= LG; i++) anc[u][i] = anc[anc[u][i - 1]][i - 1];
  tin[u] = ++ptr;
  for (__typeof(G[u].begin()) it = G[u].begin(); it != G[u].end(); it++) {
    int v = *it;
    if (v != p) {
      dfs(v, u);
    }
  }
  tout[u] = ptr;
}
int jump(int u, int d) {
  for (int i = LG; i >= 0; i--)
    if ((1 << i) <= d) {
      d -= (1 << i);
      u = anc[u][i];
    }
  return u;
}
int get_lca(int u, int v) {
  if (!u || !v) return u + v;
  if (depth[u] > depth[v]) u = jump(u, depth[u] - depth[v]);
  if (depth[v] > depth[u]) v = jump(v, depth[v] - depth[u]);
  if (u == v) return u;
  for (int i = LG; i >= 0; i--) {
    if (anc[u][i] != anc[v][i]) {
      u = anc[u][i];
      v = anc[v][i];
    }
  }
  return anc[u][0];
}
int tree[N * 5];
void build(int k, int b, int e) {
  if (b == e)
    tree[k] = b;
  else {
    build(k + k, b, (b + e) / 2);
    build(k + k + 1, (b + e) / 2 + 1, e);
    tree[k] = get_lca(tree[k + k], tree[k + k + 1]);
  }
}
int range_lca(int k, int b, int e, int x1, int x2) {
  if (b > x2 || e < x1) return 0;
  if (b >= x1 && e <= x2) return tree[k];
  return get_lca(range_lca(k + k, b, (b + e) / 2, x1, x2),
                 range_lca(k + k + 1, (b + e) / 2 + 1, e, x1, x2));
}
int f[N];
void init() {
  for (int i = 0; i < N; i++) f[i] = 0;
}
void put(int x, int by) {
  while (x < N) {
    f[x] += by;
    x += x & -x;
  }
}
int get(int x) {
  int res = 0;
  while (x > 0) {
    res += f[x];
    x -= x & -x;
  }
  return res;
}
int get(int l, int r) { return get(r) - get(l - 1); }
int size, root;
void insert(int u) {
  if (size == 0) {
    root = u;
    size = 1;
    put(tin[u], +1);
    return;
  }
  int lca = get_lca(root, u);
  if (lca != root) {
    size += depth[u] + depth[root] - 2 * depth[lca];
    root = lca;
  } else if (get(tin[u], tout[u]) == 0) {
    int x = u;
    for (int i = LG; i >= 0; i--) {
      int v = anc[x][i];
      if (v > 0 && get(tin[v], tout[v]) == 0) {
        x = v;
        size += (1 << i);
      }
    }
    ++size;
  }
  put(tin[u], +1);
}
void remove(int u, int l, int r) {
  if (size == 1) {
    size = 0;
    return;
  }
  put(tin[u], -1);
  int nroot = range_lca(1, 1, n, l, r);
  if (nroot != root) {
    if (nroot == root) return;
    size -= depth[nroot] + depth[u] - 2 * depth[root];
    root = nroot;
    ;
    return;
  }
  if (get(tin[u], tout[u]) == 0) {
    int x = u;
    for (int i = LG; i >= 0; i--) {
      int v = anc[x][i];
      if (v > 0 && get(tin[v], tout[v]) == 0) {
        x = v;
        size -= (1 << i);
      }
    }
    --size;
    assert(size >= 0);
  }
}
bool can(int len) {
  init();
  size = 0;
  for (int i = 1; i < len; i++) insert(i);
  for (int i = len; i <= n; i++) {
    insert(i);
    if (i > len) remove(i - len, i - len + 1, i);
    ;
    if (size <= k) return true;
  }
  return false;
}
int main() {
  n = read();
  k = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read();
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1, 0);
  build(1, 1, n);
  int l = 0, r = k + 1;
  while (l + 1 < r) {
    int m = (l + r) >> 1;
    if (can(m))
      l = m;
    else
      r = m;
  }
  printf("%d\n", l);
  return 0;
}

### Prompt

Develop a solution in cpp to the problem described below:

There is a tree consisting of n vertices. The vertices are numbered from 1 to n.

Let's define the length of an interval [l, r] as the value r - l + 1. The score of a subtree of this tree is the maximum length of such an interval [l, r] that, the vertices with numbers l, l + 1, ..., r belong to the subtree.

Considering all subtrees of the tree whose size is at most k, return the maximum score of the subtree. Note, that in this problem tree is not rooted, so a subtree — is an arbitrary connected subgraph of the tree.

Input

There are two integers in the first line, n and k (1 ≤ k ≤ n ≤ 105). Each of the next n - 1 lines contains integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi). That means ai and bi are connected by a tree edge.

It is guaranteed that the input represents a tree.

Output

Output should contain a single integer — the maximum possible score.

Examples

Input

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


Output

3


Input

16 7
13 11
12 11
2 14
8 6
9 15
16 11
5 14
6 15
4 3
11 15
15 14
10 1
3 14
14 7
1 7


Output

6

Note

For the first case, there is some subtree whose size is at most 6, including 3 consecutive numbers of vertices. For example, the subtree that consists of {1, 3, 4, 5, 7, 8} or of {1, 4, 6, 7, 8, 10} includes 3 consecutive numbers of vertices. But there is no subtree whose size is at most 6, which includes 4 or more consecutive numbers of vertices.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 5757;
const long long Linf = (long long)1e18 + 5757;
template <class T>
inline void umax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void umin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <class T>
inline T lcm(T a, T b) {
  return a / __gcd(a, b) * b;
}
inline int read() {
  int x;
  scanf(" %d", &x);
  return x;
}
const int N = 101010;
const int LG = 20;
int n, k;
vector<int> G[N];
int anc[N][LG + 1];
int tin[N], tout[N], ptr = 0;
int depth[N];
void dfs(int u, int p) {
  depth[u] = depth[p] + 1;
  anc[u][0] = p;
  for (int i = 1; i <= LG; i++) anc[u][i] = anc[anc[u][i - 1]][i - 1];
  tin[u] = ++ptr;
  for (__typeof(G[u].begin()) it = G[u].begin(); it != G[u].end(); it++) {
    int v = *it;
    if (v != p) {
      dfs(v, u);
    }
  }
  tout[u] = ptr;
}
int jump(int u, int d) {
  for (int i = LG; i >= 0; i--)
    if ((1 << i) <= d) {
      d -= (1 << i);
      u = anc[u][i];
    }
  return u;
}
int get_lca(int u, int v) {
  if (!u || !v) return u + v;
  if (depth[u] > depth[v]) u = jump(u, depth[u] - depth[v]);
  if (depth[v] > depth[u]) v = jump(v, depth[v] - depth[u]);
  if (u == v) return u;
  for (int i = LG; i >= 0; i--) {
    if (anc[u][i] != anc[v][i]) {
      u = anc[u][i];
      v = anc[v][i];
    }
  }
  return anc[u][0];
}
int tree[N * 5];
void build(int k, int b, int e) {
  if (b == e)
    tree[k] = b;
  else {
    build(k + k, b, (b + e) / 2);
    build(k + k + 1, (b + e) / 2 + 1, e);
    tree[k] = get_lca(tree[k + k], tree[k + k + 1]);
  }
}
int range_lca(int k, int b, int e, int x1, int x2) {
  if (b > x2 || e < x1) return 0;
  if (b >= x1 && e <= x2) return tree[k];
  return get_lca(range_lca(k + k, b, (b + e) / 2, x1, x2),
                 range_lca(k + k + 1, (b + e) / 2 + 1, e, x1, x2));
}
int f[N];
void init() {
  for (int i = 0; i < N; i++) f[i] = 0;
}
void put(int x, int by) {
  while (x < N) {
    f[x] += by;
    x += x & -x;
  }
}
int get(int x) {
  int res = 0;
  while (x > 0) {
    res += f[x];
    x -= x & -x;
  }
  return res;
}
int get(int l, int r) { return get(r) - get(l - 1); }
int size, root;
void insert(int u) {
  if (size == 0) {
    root = u;
    size = 1;
    put(tin[u], +1);
    return;
  }
  int lca = get_lca(root, u);
  if (lca != root) {
    size += depth[u] + depth[root] - 2 * depth[lca];
    root = lca;
  } else if (get(tin[u], tout[u]) == 0) {
    int x = u;
    for (int i = LG; i >= 0; i--) {
      int v = anc[x][i];
      if (v > 0 && get(tin[v], tout[v]) == 0) {
        x = v;
        size += (1 << i);
      }
    }
    ++size;
  }
  put(tin[u], +1);
}
void remove(int u, int l, int r) {
  if (size == 1) {
    size = 0;
    return;
  }
  put(tin[u], -1);
  int nroot = range_lca(1, 1, n, l, r);
  if (nroot != root) {
    if (nroot == root) return;
    size -= depth[nroot] + depth[u] - 2 * depth[root];
    root = nroot;
    ;
    return;
  }
  if (get(tin[u], tout[u]) == 0) {
    int x = u;
    for (int i = LG; i >= 0; i--) {
      int v = anc[x][i];
      if (v > 0 && get(tin[v], tout[v]) == 0) {
        x = v;
        size -= (1 << i);
      }
    }
    --size;
    assert(size >= 0);
  }
}
bool can(int len) {
  init();
  size = 0;
  for (int i = 1; i < len; i++) insert(i);
  for (int i = len; i <= n; i++) {
    insert(i);
    if (i > len) remove(i - len, i - len + 1, i);
    ;
    if (size <= k) return true;
  }
  return false;
}
int main() {
  n = read();
  k = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read();
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1, 0);
  build(1, 1, n);
  int l = 0, r = k + 1;
  while (l + 1 < r) {
    int m = (l + r) >> 1;
    if (can(m))
      l = m;
    else
      r = m;
  }
  printf("%d\n", l);
  return 0;
}

```