#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
vector<int> con[100010];
int pa[100010], vis[100010], dp[100010], dis[100010], fin[100010];
int T;
void dfs(int v, int p) {
  int i, k;
  dis[v] = ++T;
  for (i = 0; i < con[v].size(); i++) {
    k = con[v][i];
    if (k == p) continue;
    dp[k] = dp[v] + 1;
    pa[k] = v;
    dfs(k, v);
  }
  fin[v] = T;
}
void Input() {
  int i, j, k;
  scanf("%d %d", &n, &m);
  for (k = 1; k < n; k++) {
    scanf("%d %d", &i, &j);
    i--;
    j--;
    con[i].push_back(j);
    con[j].push_back(i);
  }
  ans = 0;
  pa[0] = -1;
  dp[0] = 0;
  T = 0;
  dfs(0, -1);
}
int fa[18][100010];
int v[100010];
int mm[100010];
int calc_fa(int v, int l) {
  int k, vv;
  if (v < 0 || !l) return v;
  k = mm[l];
  vv = fa[k][v];
  return calc_fa(vv, l - (1 << k));
}
void Prepare() {
  int i, j, k;
  for (i = 0; i < n; i++) fa[0][i] = pa[i];
  for (k = 1; k < 18; k++) {
    for (i = 0; i < n; i++) {
      j = fa[k - 1][i];
      if (j < 0)
        fa[k][i] = j;
      else
        fa[k][i] = fa[k - 1][j];
    }
  }
  for (k = 1; k < 100010; k++) {
    for (i = 0;; i++)
      if ((1 << i) > k) break;
    mm[k] = i - 1;
  }
}
void Add(int k, int val) {
  while (k <= n) {
    v[k] += val;
    k += k & -k;
  }
}
int Calc(int k) {
  int s = 0;
  while (k) {
    s += v[k];
    k -= k & (-k);
  }
  return s;
}
int Sum(int k) { return Calc(fin[k]) - Calc(dis[k] - 1); }
int rt, rrt;
int Test(int ss, int ee, int x) {
  int i, j, k, st, en, mid, y;
  st = -1;
  en = n;
  while (en > st + 1) {
    mid = (st + en) / 2;
    y = calc_fa(x, mid);
    if (y < 0)
      en = mid - 1;
    else {
      k = Sum(y);
      if (k)
        en = mid;
      else
        st = mid;
    }
  }
  x = calc_fa(x, en);
  rrt = rt;
  if (dp[x] < dp[rt]) {
    en += dp[rt] - dp[x];
    rrt = x;
  }
  return en;
}
int doit(int ss, int ee) {
  int st, en, mid, x, y, k;
  if (Sum(ss) == ee - ss + 1) return ss;
  st = 0;
  en = n;
  x = ss;
  while (en > st + 1) {
    mid = (st + en) / 2;
    y = calc_fa(x, mid);
    if (y < 0)
      en = mid - 1;
    else {
      k = Sum(y);
      if (k == ee - ss + 1)
        en = mid;
      else
        st = mid;
    }
  }
  x = calc_fa(x, en);
  return x;
}
void Solve() {
  int i, j, k;
  Prepare();
  for (i = 0; i <= n; i++) v[i] = 0;
  int st, en, mem = 1;
  st = en = 0;
  ans = 1;
  Add(1, 1);
  rt = 0;
  for (;;) {
    for (i = en + 1; i < n; i++) {
      k = Test(st, en, i);
      if (k + mem > m) break;
      Add(dis[i], 1);
      en = i;
      mem += k;
      rt = rrt;
    }
    if (ans < en - st + 1) ans = en - st + 1;
    if (en == n - 1) break;
    if (st == en) {
      Add(dis[st], -1);
      Add(dis[st + 1], 1);
      st = en = st + 1;
      mem = 1;
      rt = st;
    } else {
      Add(dis[st], -1);
      rt = doit(st + 1, en);
      k = Test(st + 1, en, st);
      mem -= k;
      st++;
    }
  }
  printf("%d\n", ans);
}
int main() {
  Input();
  Solve();
  return 0;
}
