#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int N = 1e5 + 10, N2 = 2e6 + 10, INFI = 1e9 + 10, L = 19;
int n, k, tin[N], tout[N], up[N][L + 1], timer, d[N], cnt, mx;
vector<int> adj[N];
set<pair<int, int> > s;
void dfs(int v, int p) {
  d[v] = d[p] + 1;
  tin[v] = ++timer;
  up[v][0] = p;
  for (int i = 1; i <= L; i++) {
    up[v][i] = up[up[v][i - 1]][i - 1];
  }
  for (auto u : adj[v]) {
    if (u != p) {
      dfs(u, v);
    }
  }
  tout[v] = ++timer;
}
bool is_ancestor(int v, int u) {
  return tin[v] <= tin[u] && tout[v] >= tout[u];
}
int lca(int v, int u) {
  if (is_ancestor(v, u)) {
    return v;
  }
  if (is_ancestor(u, v)) {
    return u;
  }
  for (int i = L; i >= 0; i--) {
    if (!is_ancestor(up[v][i], u)) {
      v = up[v][i];
    }
  }
  return up[v][0];
}
int dist(int v, int u) { return d[v] + d[u] - 2 * d[lca(v, u)]; }
set<pair<int, int> >::iterator prv(set<pair<int, int> >::iterator it) {
  set<pair<int, int> >::iterator x;
  if (it == s.begin()) {
    x = --s.end();
  } else {
    x = --it;
  }
  return x;
}
set<pair<int, int> >::iterator nxt(set<pair<int, int> >::iterator it) {
  set<pair<int, int> >::iterator x;
  x = ++it;
  if (x == s.end()) {
    x = s.begin();
  }
  return x;
}
void add(int i) {
  auto it = s.insert({tin[i], i}).first;
  auto l = prv(it);
  auto r = nxt(it);
  cnt -= dist(l->second, r->second);
  cnt += dist(i, r->second);
  cnt += dist(l->second, i);
}
void del(int i) {
  auto it = s.lower_bound({tin[i], i});
  auto l = prv(it);
  auto r = nxt(it);
  cnt += dist(l->second, r->second);
  cnt -= dist(i, r->second);
  cnt -= dist(l->second, i);
  s.erase(it);
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    adj[u - 1].push_back(v - 1);
    adj[v - 1].push_back(u - 1);
  }
  dfs(0, 0);
  for (int b = 0, e = 0; e < n; e++) {
    add(e);
    while (b < e && (cnt / 2) + 1 > k) {
      del(b);
      b++;
    }
    mx = max(mx, e - b + 1);
  }
  cout << mx << endl;
  return 0;
}
