#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const long long infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
int read() {
  int tmp = 0, fh = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    tmp = tmp * 10 + ch - '0';
    ch = getchar();
  }
  return tmp * fh;
}
struct Edge {
  int data, next;
} e[100010 * 2];
set<int> mp;
int place, head[100010], p[100010], dad[100010][18 + 1], dep[100010], n, cnt, k,
    ans;
void build(int u, int v) {
  e[++place].data = v;
  e[place].next = head[u];
  head[u] = place;
}
void dfs(int x, int fa) {
  p[x] = ++place;
  dad[p[x]][0] = p[fa];
  dep[p[x]] = dep[p[fa]] + 1;
  for (int ed = head[x]; ed != 0; ed = e[ed].next)
    if (e[ed].data != fa) dfs(e[ed].data, x);
}
void pre() {
  for (int i = 1, j = 1; j * 2 <= n; j *= 2, i++)
    for (int k = 1; k <= n; k++) dad[k][i] = dad[dad[k][i - 1]][i - 1];
}
int lca(int u, int v) {
  if (dep[u] > dep[v]) swap(u, v);
  for (int i = 18; i >= 0; i--)
    if (dep[dad[v][i]] >= dep[u]) v = dad[v][i];
  if (u == v) return u;
  for (int i = 18; i >= 0; i--)
    if (dad[u][i] != dad[v][i]) u = dad[u][i], v = dad[v][i];
  return dad[u][0];
}
int dis(int u, int v) { return dep[u] + dep[v] - 2 * dep[lca(u, v)]; }
void ins(int x) {
  int l, r;
  set<int>::iterator it = mp.lower_bound(x);
  if (it == mp.end())
    r = *mp.begin();
  else
    r = *it;
  if (it == mp.begin())
    l = *(--mp.end());
  else
    l = *(--it);
  cnt = cnt - dis(l, r) + dis(l, x) + dis(x, r);
  mp.insert(x);
  if (cnt / 2 + 1 <= k) ans = max(ans, (int)mp.size());
}
void del(int x) {
  int l, r;
  mp.erase(x);
  set<int>::iterator it = mp.lower_bound(x);
  if (it == mp.end())
    r = *mp.begin();
  else
    r = *it;
  if (it == mp.begin())
    l = *(--mp.end());
  else
    l = *(--it);
  cnt = cnt + dis(l, r) - dis(l, x) - dis(x, r);
  if (cnt / 2 + 1 <= k) ans = max(ans, (int)mp.size());
}
int main() {
  n = read(), k = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read();
    build(u, v);
    build(v, u);
  }
  place = 0;
  dfs(1, 0);
  pre();
  mp.insert(p[1]);
  ans = 1;
  for (int i = 1, j = 1; i <= n; i++) {
    while (j < n && cnt / 2 + 1 <= k) ins(p[++j]);
    if (i != n) del(p[i]);
  }
  printf("%d\n", ans);
  return 0;
}
