#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 1;
const int N = 100123;
int z, n, a, b, k, res = 1;
int pre[N];
int post[N];
int par[N];
int h[N];
int up[20][N];
vector<int> nbs[N];
vector<int> dfs_order;
int T;
bool cmp(int a, int b) { return pre[a] < pre[b]; }
bool in_subtree(int a, int b) { return pre[a] <= pre[b] && post[a] >= post[b]; }
void dfs1(int v, int p, int ch) {
  pre[v] = T++;
  par[v] = p;
  h[v] = ch;
  for (int w : nbs[v])
    if (w != p) {
      dfs1(w, v, ch + 1);
    }
  post[v] = T++;
}
void compute_lca() {
  for (int i = 0; i < n; i++) up[0][i] = par[i];
  for (int i = 1; i < 20; i++) {
    for (int v = 0; v < n; v++) {
      up[i][v] = up[i - 1][up[i - 1][v]];
    }
  }
}
int lca(int v, int w) {
  int i = 19;
  while (i >= 0) {
    if (!in_subtree(up[i][v], w)) {
      v = up[i][v];
    }
    i--;
  }
  if (!in_subtree(v, w)) v = par[v];
  return v;
}
int dst(int v, int w) {
  int lc = lca(v, w);
  return h[v] - h[lc] + h[w] - h[lc];
}
struct set_cmp {
  bool operator()(const int& a, const int& b) const { return pre[a] < pre[b]; }
};
set<int, set_cmp> s;
int process(int v, int val) {
  s.insert(v);
  if (s.size() == 1) {
    return 0;
  }
  auto it = s.find(v);
  auto nit = it;
  nit++;
  auto pit = it;
  pit--;
  int nx, pv;
  if (it == s.begin()) {
    nx = *nit;
    if (s.size() == 2) {
      return val * dst(nx, v);
    }
    nit++;
    pv = *s.rbegin();
  } else if (nit == s.end()) {
    pv = *pit;
    if (s.size() == 2) {
      return val * dst(pv, v);
    }
    pit--;
    nx = *s.begin();
  } else {
    nx = *nit;
    pv = *pit;
  }
  return val * (dst(pv, v) + dst(nx, v) - dst(pv, nx)) / 2;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  k--;
  if (n <= 1) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    --a;
    --b;
    nbs[a].push_back(b);
    nbs[b].push_back(a);
  }
  dfs1(0, 0, 0);
  for (int i = 0; i < n; i++) dfs_order.push_back(i);
  sort(dfs_order.begin(), dfs_order.end(), cmp);
  compute_lca();
  int b = 0;
  int sz = 0;
  int next_sz = 0;
  s.insert(b);
  for (int a = 0; a < n; a++) {
    while (b + 1 < n) {
      next_sz = sz + process(b + 1, 1);
      if (next_sz > k) {
        s.erase(s.find(b + 1));
        break;
      }
      sz = next_sz;
      b++;
    }
    res = max(res, b - a + 1);
    sz += process(a, -1);
    s.erase(s.find(a));
  }
  cout << res << endl;
}
