#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int MAXN = 100006, LOG = 17;
vector<int> V[MAXN];
int tin[MAXN], tout[MAXN], H[MAXN], P[LOG][MAXN];
inline bool upodv(int u, int v) { return tin[u] >= tin[v] && tin[u] < tout[v]; }
int lca(int u, int v) {
  if (upodv(u, v)) return v;
  if (upodv(v, u)) return u;
  int i = u;
  for (int j = LOG - 1; j >= 0;) {
    if (upodv(v, P[j][i]))
      j--;
    else
      i = P[j][i];
  }
  return P[0][i];
}
int ct;
void dfs(int u, int par) {
  tin[u] = ct++;
  ;
  for (auto it = (V[u]).begin(); it != (V[u]).end(); ++it)
    if (*it != par) {
      H[*it] = H[u] + 1;
      P[0][*it] = u;
      dfs(*it, u);
    }
  tout[u] = ct;
}
inline int odl(int u, int v) { return H[u] + H[v] - 2 * H[lca(u, v)]; }
struct cmp {
  inline bool operator()(const int &a, const int &b) { return tin[a] < tin[b]; }
};
set<int, cmp> S;
int licz(int u) {
  if (S.size() == 1) return 1;
  auto it = S.find(u);
  if (it != S.begin() && u != *(S.rbegin())) {
    ;
    auto it2 = it;
    it2--;
    int pre = *it2;
    it2 = it;
    it2++;
    int ne = *it2;
    ;
    return min(abs(H[u] - H[lca(u, ne)]), abs(H[u] - H[lca(u, pre)]));
  }
  int sas, skraj;
  if (it == S.begin()) {
    ;
    ++it;
    sas = *it;
    skraj = *(S.rbegin());
  } else {
    ;
    --it;
    sas = *it;
    skraj = *(S.begin());
  }
  int Y = lca(u, sas), X = lca(skraj, sas);
  ;
  return H[u] - H[Y] + max(0, H[X] - H[Y]);
}
int SUMA;
void dodaj(int u) {
  S.insert(u);
  SUMA += licz(u);
  ;
}
void usun(int u) {
  SUMA -= licz(u);
  S.erase(u);
  ;
}
int main() {
  int n, kk;
  scanf("%d%d", &n, &kk);
  for (int i = 0; i < (n - 1); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    V[a].push_back(b);
    V[b].push_back(a);
  }
  dfs(0, -1);
  for (int i = 1; i < LOG; ++i)
    for (int j = 1; j <= n; ++j) P[i][j] = P[i - 1][P[i - 1][j]];
  int ret = 1;
  int ko = -1;
  for (int po = 0; po < (n); ++po) {
    ;
    if (ko < po) {
      dodaj(po);
      ++ko;
    }
    if (po) usun(po - 1);
    if (SUMA <= kk) ret = max(ret, ko - po + 1);
    while (ko + 1 < n) {
      dodaj(ko + 1);
      ko++;
      if (SUMA <= kk)
        ret = max(ret, ko - po + 1);
      else
        break;
    }
  }
  printf("%d\n", ret);
  return 0;
}
