#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
using namespace std;
long long poww(long long a, long long b, long long md) {
  return (!b ? 1
             : (b & 1 ? a * poww(a * a % md, b / 2, md) % md
                      : poww(a * a % md, b / 2, md) % md));
}
const int maxn = 1000 * 100 + 5;
const long long inf = 9223372036854775807;
const long long mod = 1e9 + 7;
const long long lg = 18;
int n, k, st[maxn], mark[maxn], ans, l, par[lg][maxn], h[maxn], cnt, lp, rp;
vector<int> adj[maxn];
void dfs(int v) {
  mark[v] = 1;
  cnt++;
  st[v] = cnt;
  for (auto u : adj[v]) {
    if (!mark[u]) {
      par[0][u] = v;
      for (int i = 1; i < lg; i++) {
        par[i][u] = par[i - 1][par[i - 1][u]];
      }
      h[u] = h[v] + 1;
      dfs(u);
    }
  }
}
int lca(int u, int v) {
  if (h[u] > h[v]) swap(u, v);
  for (int i = lg - 1; i >= 0; i--) {
    if (h[par[i][v]] >= h[u]) v = par[i][v];
  }
  if (v == u) return u;
  for (int i = lg - 1; i >= 0; i--) {
    if (par[i][v] != par[i][u]) {
      v = par[i][v];
      u = par[i][u];
    }
  }
  return par[0][u];
}
int d(int u, int v) { return h[u] + h[v] - h[lca(u, v)] * 2; }
struct cmp {
  bool operator()(const int &a, const int &b) { return st[a] < st[b]; }
};
set<int, cmp> s;
set<int, cmp>::iterator p;
void add(int u) {
  s.insert(u);
  if ((long long)(s).size() == 1) {
    return;
  }
  p = s.lower_bound(u);
  if (p == s.begin()) {
    lp = *prev(s.end());
  } else {
    lp = *prev(p);
  }
  if (next(p) == s.end()) {
    rp = *s.begin();
  } else {
    rp = *next(p);
  }
  l += d(lp, u) + d(u, rp) - d(lp, rp);
}
void del(int u) {
  if ((long long)(s).size() == 1) {
    s.erase(u);
    return;
  }
  p = s.lower_bound(u);
  if (p == s.begin()) {
    lp = *prev(s.end());
  } else {
    lp = *prev(p);
  }
  if (next(p) == s.end()) {
    rp = *s.begin();
  } else {
    rp = *next(p);
  }
  l -= d(lp, u) + d(u, rp) - d(lp, rp);
  s.erase(u);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  h[0] = -1;
  cin >> n >> k;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1);
  int L = 1;
  for (int i = 1; i <= n; i++) {
    add(i);
    while (l / 2 + 1 > k) {
      del(L);
      L++;
    }
    ans = max(ans, i - L + 1);
  }
  cout << ans;
}
