#include <bits/stdc++.h>
using namespace std;
const int N_MAX = 110000;
int f[N_MAX][20], dep[N_MAX], ver[N_MAX], num[N_MAX], len, cnt;
vector<int> a[N_MAX];
set<int> s;
void dfs(int u, int p) {
  f[u][0] = p;
  num[u] = ++cnt;
  ver[cnt] = u;
  for (int i = 0; f[u][i]; i++) f[u][i + 1] = f[f[u][i]][i];
  for (vector<int>::iterator i = a[u].begin(); i != a[u].end(); i++) {
    if (*i == p) continue;
    dep[*i] = dep[u] + 1;
    dfs(*i, u);
  }
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  int d = dep[u] - dep[v], i;
  for (i = 0; i < 20; i++)
    if (d & (1 << i)) u = f[u][i];
  if (u == v) return u;
  for (i = 19; ~i; i--)
    if (f[u][i] != f[v][i]) u = f[u][i], v = f[v][i];
  return f[u][0];
}
int dis(int u, int v) {
  u = ver[u];
  v = ver[v];
  return dep[u] + dep[v] - dep[lca(u, v)] * 2;
}
void insert(int p) {
  p = num[p];
  set<int>::iterator i = s.lower_bound(p);
  int x, y;
  set<int>::iterator j = s.begin();
  if (i == s.begin())
    x = *s.rbegin();
  else {
    --i;
    x = *i;
    ++i;
  }
  if (i == s.end())
    y = *s.begin();
  else
    y = *i;
  len -= dis(x, y);
  len += dis(p, x) + dis(p, y);
  s.insert(p);
}
void erase(int p) {
  p = num[p];
  set<int>::iterator i = s.lower_bound(p);
  int x, y;
  if (i == s.begin())
    x = *s.rbegin();
  else {
    --i;
    x = *i;
    ++i;
  }
  if (++i == s.end())
    y = *s.begin();
  else
    y = *i;
  len -= dis(p, x) + dis(p, y);
  len += dis(x, y);
  s.erase(p);
}
bool gao() {
  int l = 0;
  for (set<int>::iterator i = s.begin(), j; i != s.end(); i++) {
    j = i;
    ++j;
    if (j == s.end()) j = s.begin();
    l += dis(*i, *j);
  }
  return l == len;
}
int main() {
  int N, lim, i;
  cin >> N >> lim;
  --lim;
  for (i = 1; i < N; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  dfs(1, 0);
  int l = 1, r = 1, ans = 1;
  s.insert(1);
  while (r < N) {
    insert(++r);
    while (len > lim * 2) erase(l++);
    ans = max(ans, r - l + 1);
  }
  cout << ans << endl;
}
