#include <bits/stdc++.h>
using namespace std;
int ord[100100];
int inv_ord[100100];
int dep[100100];
int fa[100100][17];
vector<int> g[100100];
set<int> ss;
int ts;
void dfs(int p, int f) {
  ord[p] = ++ts;
  inv_ord[ord[p]] = p;
  dep[p] = dep[f] + 1;
  fa[p][0] = f;
  for (int i = 0; i < 16; i++) fa[p][i + 1] = fa[fa[p][i]][i];
  for (int i = 0; i < g[p].size(); i++)
    if (g[p][i] != f) dfs(g[p][i], p);
}
inline int bit(int x, int i) { return (x >> i) & 1; }
int lca(int a, int b) {
  if (dep[a] > dep[b]) swap(a, b);
  for (int i = 0; i < 17; i++)
    if (bit(dep[a] - dep[b], i)) b = fa[b][i];
  if (a == b) return a;
  for (int i = 16; i >= 0; i--)
    if (fa[a][i] != fa[b][i]) a = fa[a][i], b = fa[b][i];
  return fa[a][0];
}
int calc(int p) {
  if (ss.empty()) return 1;
  set<int>::iterator it = ss.lower_bound(ord[p]);
  int a = inv_ord[it == ss.end() ? *ss.begin() : *it];
  int b = inv_ord[it == ss.begin() ? *ss.rbegin() : *--it];
  return dep[p] - dep[lca(a, p)] - dep[lca(b, p)] + dep[lca(a, b)];
}
int main() {
  int n, k, a, b;
  while (cin >> n >> k) {
    for (int i = 1; i < n; i++) {
      cin >> a >> b;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    ts = 0;
    dfs(1, 0);
    int v = 0;
    int sol = 1;
    for (int i = 1, j = 0; i <= n; i++) {
      while (v <= k) {
        sol = max(sol, j - i + 1);
        if (j == n) break;
        j++;
        v += calc(j);
        ss.insert(ord[j]);
      }
      ss.erase(ord[i]);
      v -= calc(i);
    }
    cout << sol << endl;
  }
  return 0;
}
