#include <bits/stdc++.h>
using namespace std;
const int N = 210010;
struct tree {
  int lt, rt, flag, sum;
  int dis() { return rt - lt + 1; }
} a[N * 4];
void init(int lt, int rt, int step) {
  a[step].lt = lt;
  a[step].rt = rt;
  a[step].flag = a[step].sum = 0;
  if (lt == rt) return;
  int mid = (lt + rt) / 2;
  init(lt, mid, 2 * step);
  init(mid + 1, rt, 2 * step + 1);
}
void insert(int lt, int rt, int step, int val) {
  if (a[step].lt == lt && a[step].rt == rt) {
    a[step].flag += val;
    if (a[step].flag)
      a[step].sum = a[step].dis();
    else
      a[step].sum = a[2 * step].sum + a[2 * step + 1].sum;
    return;
  }
  if (rt <= a[2 * step].rt)
    insert(lt, rt, 2 * step, val);
  else if (lt > a[2 * step].rt)
    insert(lt, rt, 2 * step + 1, val);
  else {
    insert(lt, a[2 * step].rt, 2 * step, val);
    insert(a[2 * step + 1].lt, rt, 2 * step + 1, val);
  }
  if (a[step].flag)
    a[step].sum = a[step].dis();
  else
    a[step].sum = a[2 * step].sum + a[2 * step + 1].sum;
}
struct edge {
  int v, next;
} e[N * 2];
int head[N], cnt;
int top[N], fa[N], dep[N], size[N], son[N], w[N], e_num;
void init() {
  memset(head, -1, sizeof(head));
  cnt = e_num = 0;
  memset(top, 0, sizeof(top));
  memset(fa, 0, sizeof(fa));
  memset(dep, 0, sizeof(dep));
  memset(size, 0, sizeof(size));
  memset(son, 0, sizeof(son));
  memset(w, 0, sizeof(w));
}
void addedge(int u, int v) {
  e[cnt].v = v;
  e[cnt].next = head[u];
  head[u] = cnt++;
}
void dfs(int u) {
  size[u] = 1;
  for (int i = head[u]; i != -1; i = e[i].next)
    if (e[i].v != fa[u]) {
      dep[e[i].v] = dep[u] + 1;
      fa[e[i].v] = u;
      dfs(e[i].v);
      size[u] += size[e[i].v];
      if (size[son[u]] < size[e[i].v]) son[u] = e[i].v;
    }
}
void dfs(int u, int tp) {
  w[u] = ++e_num;
  top[u] = tp;
  if (son[u]) dfs(son[u], tp);
  for (int i = head[u]; i != -1; i = e[i].next)
    if (e[i].v != fa[u] && e[i].v != son[u]) dfs(e[i].v, e[i].v);
}
void find(int x, int y, int val) {
  int fx = top[x], fy = top[y];
  while (fx != fy) {
    if (dep[fx] < dep[fy]) swap(fx, fy), swap(x, y);
    insert(w[fx], w[x], 1, val);
    x = fa[fx];
    fx = top[x];
  }
  if (dep[x] > dep[y]) swap(x, y);
  insert(w[x], w[y], 1, val);
}
int main() {
  int n, m, x, y;
  cin >> n >> m;
  init();
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    addedge(x, y);
    addedge(y, x);
  }
  int root = rand() % n + 1;
  dfs(root);
  dfs(root, root);
  init(0, e_num + 1, 1);
  int ans = 1, pos = 2;
  for (int i = 2; i <= n; i++) {
    find(i, i - 1, 1);
    while (a[1].sum > m) {
      find(pos - 1, pos, -1);
      pos++;
    }
    if (pos <= i) ans = max(ans, i - pos + 2);
  }
  cout << ans << endl;
  return 0;
}
