#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
const int N = 1e5 + 10;
const int L = 20;
const int MOD = 1e9 + 7;
const long double eps = 1e-12;
int n, q, par[N][L], st[N], cnt, dep[N];
long long dist[N][L], ans;
vector<pair<int, int> > e[N];
set<pair<int, int> > s;
void dfs(int v = 0, int p = 0, int w = 0) {
  par[v][0] = p;
  st[v] = cnt++;
  dist[v][0] = w;
  dep[v] = dep[p] + 1;
  for (int i = 1; i < L; i++)
    par[v][i] = par[par[v][i - 1]][i - 1],
    dist[v][i] = dist[v][i - 1] + dist[par[v][i - 1]][i - 1];
  for (int i = 0; i < e[v].size(); i++)
    if (e[v][i].first != p) dfs(e[v][i].first, v, e[v][i].second);
}
long long Dist(int v, int u) {
  if (dep[v] < dep[u]) swap(v, u);
  int dif = dep[v] - dep[u];
  long long res = 0;
  for (int i = 0; i < L; i++)
    if (dif & (1 << i)) res += dist[v][i], v = par[v][i];
  if (u == v) return res;
  for (int i = L - 1; i >= 0; i--)
    if (par[v][i] != par[u][i])
      res += dist[v][i] + dist[u][i], v = par[v][i], u = par[u][i];
  res += (dist[v][0] + dist[u][0]);
  return res;
}
void add(int v) {
  auto jt = s.insert({st[v], v});
  if (s.size() == 1) return;
  auto it = jt.first;
  if (it == s.begin()) {
    ans += Dist(s.rbegin()->second, v);
    it++;
    ans += Dist(it->second, v);
    ans -= Dist(s.rbegin()->second, it->second);
    return;
  }
  auto po = it;
  po++;
  if (po == s.end()) {
    ans += Dist(s.begin()->second, v);
    it--;
    ans += Dist(it->second, v);
    ans -= Dist(it->second, s.begin()->second);
    return;
  }
  ans += Dist(po->second, v);
  it--;
  ans += Dist(it->second, v);
  ans -= Dist(it->second, po->second);
  return;
}
void rem(int v) {
  auto it = s.find({st[v], v});
  if (s.size() == 1) {
    s.erase({st[v], v});
    return;
  }
  if (it == s.begin()) {
    ans -= Dist(s.rbegin()->second, v);
    it++;
    ans -= Dist(it->second, v);
    ans += Dist(s.rbegin()->second, it->second);
    s.erase({st[v], v});
    return;
  }
  auto po = it;
  po++;
  if (po == s.end()) {
    ans -= Dist(s.begin()->second, v);
    it--;
    ans -= Dist(it->second, v);
    ans += Dist(it->second, s.begin()->second);
    s.erase({st[v], v});
    return;
  }
  ans -= Dist(po->second, v);
  it--;
  ans -= Dist(it->second, v);
  ans += Dist(it->second, po->second);
  s.erase({st[v], v});
}
int main() {
  n = in();
  int k = in();
  k--;
  for (int i = 1; i < n; i++) {
    int a = in(), b = in(), w = 1;
    a--, b--;
    e[a].push_back({b, w});
    e[b].push_back({a, w});
  }
  dfs();
  int r = n - 1, res = 0;
  for (int i = n - 1; i >= 0; i--) {
    add(i);
    while (ans / 2 > k) {
      rem(r);
      r--;
    }
    res = max(res, r - i + 1);
  }
  cout << res << endl;
  return 0;
}
