#include <bits/stdc++.h>
using namespace std;
vector<int> e[100050];
set<int> st;
int fa[100050][20];
int p[100050];
int dfn[100050];
int cid;
int d[100050];
void dfs(int cur, int f) {
  dfn[++cid] = cur;
  p[cur] = cid;
  for (int i = 1; i < 20; ++i) fa[cur][i] = fa[fa[cur][i - 1]][i - 1];
  for (int i = 0; i < e[cur].size(); ++i) {
    int u = e[cur][i];
    if (u == f) continue;
    d[u] = d[cur] + 1;
    fa[u][0] = cur;
    dfs(u, cur);
  }
}
int lca(int u, int v) {
  if (d[u] < d[v]) swap(u, v);
  for (int i = 19; i >= 0; --i) {
    if (d[fa[u][i]] >= d[v]) u = fa[u][i];
    if (u == v) return u;
  }
  for (int i = 19; i >= 0; --i) {
    if (fa[u][i] != fa[v][i]) {
      u = fa[u][i];
      v = fa[v][i];
    }
  }
  return fa[u][0];
}
int add(int u) {
  if (st.empty()) return 1;
  int x, y;
  set<int>::iterator it = st.lower_bound(p[u]), itx = it;
  itx--;
  if (it == st.end() || it == st.begin()) {
    it = st.begin();
    itx = st.end();
    itx--;
  }
  y = (*it);
  x = (*itx);
  y = dfn[y];
  x = dfn[x];
  return d[u] - d[lca(x, u)] - d[lca(y, u)] + d[lca(x, y)];
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  for (int i = 0; i < 20; ++i) fa[1][0] = 1;
  d[1] = 1;
  dfs(1, -1);
  int now = 1;
  int ans = 1;
  int sum = 0;
  for (int i = 1; i <= n; ++i) {
    while (now <= n) {
      int tmp = add(now);
      if (sum + tmp <= k) {
        st.insert(p[now]);
        sum += tmp;
        now++;
      } else {
        break;
      }
    }
    ans = ((ans) > (now - i) ? (ans) : (now - i));
    st.erase(p[i]);
    sum -= add(i);
  }
  printf("%d\n", ans);
  return 0;
}
