#include <bits/stdc++.h>
using namespace std;
const int N = 100000, LL = 20;
int q[N + 3], Fa[LL + 3][N + 3], dep[N + 3], L[N + 3], Ti[N + 3];
int go[N * 2 + 3], t[N * 2 + 3], last[N + 3], NowT[N + 3], n, K, en, Lar, ls,
    Dn, ans;
set<int> A;
void add(int u, int v) {
  go[++en] = v;
  t[en] = last[u];
  last[u] = en;
}
void Dfs() {
  q[++ls] = 1;
  NowT[1] = last[1];
  dep[1] = 1;
  L[1] = ++Dn;
  Ti[1] = 1;
  for (; ls;) {
    int x = q[ls];
    for (; L[go[NowT[x]]]; NowT[x] = t[NowT[x]])
      ;
    if (!NowT[x]) {
      ls--;
      continue;
    }
    q[++ls] = go[NowT[x]];
    NowT[q[ls]] = last[q[ls]];
    L[q[ls]] = ++Dn;
    Ti[Dn] = q[ls];
    Fa[0][q[ls]] = x;
    dep[q[ls]] = dep[x] + 1;
  }
}
void Da() {
  for (int j = 1; j <= LL; j++)
    for (int i = 1; i <= n; i++) Fa[j][i] = Fa[j - 1][Fa[j - 1][i]];
}
int Lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  int dd = dep[x] - dep[y];
  for (int i = 0; i <= LL; i++)
    if ((dd >> i) & 1) x = Fa[i][x];
  if (x == y) return x;
  for (int i = LL; i >= 0; i--)
    if (Fa[i][x] != Fa[i][y]) x = Fa[i][x], y = Fa[i][y];
  return Fa[0][x];
}
void find(int w, int &u, int &v) {
  set<int>::iterator x = A.lower_bound(L[w]);
  if (x == A.end()) {
    u = *A.begin(), v = *(--x);
    return;
  }
  if (x == A.begin()) {
    u = *x;
    set<int>::iterator y = A.end();
    v = *(--y);
    return;
  }
  v = *x;
  u = *(--x);
}
int Calc(int w) {
  if (A.empty()) return 1;
  int u, v;
  find(w, u, v);
  u = Ti[u], v = Ti[v];
  return dep[w] - dep[Lca(w, u)] - dep[Lca(w, v)] + dep[Lca(u, v)];
}
void Insert(int w) {
  Lar += Calc(w);
  A.insert(L[w]);
}
void Del(int w) {
  A.erase(L[w]);
  Lar -= Calc(w);
}
int main() {
  scanf("%d%d", &n, &K);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  Dfs();
  Da();
  int r = 0;
  for (int i = 1; i <= n; i++) {
    for (; Lar <= K && r < n;) Insert(++r);
    if (Lar > K) Del(r--);
    ans = max(ans, r - i + 1);
    Del(i);
  }
  printf("%d", ans);
}
