#include <bits/stdc++.h>
using namespace std;
const int maxn = 150000;
const int maxk = 20;
vector<int> e[maxn];
int tim = 0;
int tin[maxn], par[maxn], d[maxn];
int jump[maxk][maxn];
int N, K;
void dfs(int v, int p) {
  tin[v] = tim++;
  par[v] = p;
  d[v] = p == -1 ? 0 : d[p] + 1;
  for (int i = 0; i < (int)(e[v].size()); ++i) {
    int u = e[v][i];
    if (u == p) {
      continue;
    }
    dfs(u, v);
  }
}
void build_jump() {
  for (int i = 0; i < (int)(N); ++i) {
    jump[0][i] = par[i];
  }
  for (int k = 1; k < maxk; ++k) {
    for (int i = 0; i < (int)(N); ++i) {
      jump[k][i] = jump[k - 1][i] == -1 ? -1 : jump[k - 1][jump[k - 1][i]];
    }
  }
}
int make_jump(int v, int dd) {
  for (int i = maxk - 1; i >= 0; --i) {
    if ((1 << i) <= dd) {
      v = jump[i][v];
      dd -= (1 << i);
    }
  }
  return v;
}
int lca(int u, int v) {
  if (d[u] < d[v]) {
    swap(u, v);
  }
  u = make_jump(u, d[u] - d[v]);
  if (u == v) {
    return u;
  }
  for (int k = maxk - 1; k >= 0; --k) {
    if (jump[k][u] != jump[k][v]) {
      u = jump[k][u];
      v = jump[k][v];
    }
  }
  return par[u];
}
int path(int u, int v) { return d[u] + d[v] - 2 * d[lca(u, v)]; }
set<pair<int, int> >::iterator next(const set<pair<int, int> >& inst,
                                    set<pair<int, int> >::iterator it) {
  ++it;
  return it == inst.end() ? inst.begin() : it;
}
set<pair<int, int> >::iterator prev(const set<pair<int, int> >& inst,
                                    set<pair<int, int> >::iterator it) {
  if (it == inst.begin()) {
    it = inst.end();
  }
  --it;
  return it;
}
int main() {
  scanf("%d%d", &N, &K);
  for (int i = 0; i < (int)(N - 1); ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u;
    --v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  dfs(0, -1);
  build_jump();
  int l = 1, r = N + 1;
  while (r - l > 1) {
    int m = (l + r) / 2;
    cerr << m << '\n';
    set<pair<int, int> > vert;
    bool ok = false;
    for (int i = 0; i < (int)(m); ++i) {
      vert.insert(make_pair(tin[i], i));
    }
    int sd = 0;
    for (auto it = vert.begin(); it != vert.end(); ++it) {
      sd += path(it->second, next(vert, it)->second);
    }
    if (sd <= 2 * (K - 1)) {
      ok = true;
    }
    for (int i = m; i < N; ++i) {
      vert.insert(make_pair(tin[i], i));
      auto it = vert.find(make_pair(tin[i], i));
      auto pit = prev(vert, it), nit = next(vert, it);
      sd += path(it->second, pit->second) + path(it->second, nit->second) -
            path(pit->second, nit->second);
      it = vert.find(make_pair(tin[i - m], i - m));
      pit = prev(vert, it), nit = next(vert, it);
      sd -= path(it->second, pit->second) + path(it->second, nit->second) -
            path(pit->second, nit->second);
      vert.erase(it);
      if (sd <= 2 * (K - 1)) {
        ok = true;
      }
    }
    if (ok) {
      l = m;
    } else {
      r = m;
    }
  }
  cout << l << '\n';
  return 0;
}
