#include <bits/stdc++.h>
using namespace std;
template <typename T>
T nextInt() {
  T x = 0, p = 1;
  char ch;
  do {
    ch = getchar();
  } while (ch <= ' ');
  if (ch == '-') {
    p = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * p;
}
const int maxN = (int)1e5 + 10;
const int maxL = 17;
const int mod = (int)1e9 + 7;
const int INF = (int)1e9 + 5;
const long long LLINF = (long long)1e18 + 5;
int n, k;
vector<int> g[maxN];
int tin[maxN];
int tout[maxN];
int timer;
int up[maxN][maxL];
int depth[maxN];
int have[maxN];
void dfs(int v, int p = 0) {
  tin[v] = timer++;
  up[v][0] = p;
  depth[v] = depth[p] + 1;
  for (int i = 1; i < maxL; ++i) {
    up[v][i] = up[up[v][i - 1]][i - 1];
  }
  for (int x : g[v]) {
    if (x == p) continue;
    dfs(x, v);
  }
  tout[v] = timer++;
}
bool is_ancestor(int x, int y) {
  return tin[x] <= tin[y] && tout[x] >= tout[y];
}
int lca(int x, int y) {
  if (is_ancestor(x, y)) return x;
  if (is_ancestor(y, x)) return y;
  for (int i = maxL - 1; i >= 0; --i) {
    if (up[x][i] != 0 && !is_ancestor(up[x][i], y)) {
      x = up[x][i];
    }
  }
  return up[x][0];
}
int get_dist(int x, int y) {
  int z = lca(x, y);
  return depth[x] - depth[z];
}
set<pair<int, int> > s;
int d = 0;
int calc() { return d + 1; }
void append(int v) {
  if (s.empty()) {
    s.insert(make_pair(tin[v], v));
    d = 0;
    return;
  }
  auto r = s.lower_bound(make_pair(tin[v], v));
  auto l = prev(r);
  if (r == s.end())
    r = s.begin();
  else if (r == s.begin())
    l = prev(s.end());
  d -= get_dist(l->second, r->second);
  d += get_dist(l->second, v);
  d += get_dist(v, r->second);
  s.insert(make_pair(tin[v], v));
}
void extract(int v) {
  if (s.size() == 1) {
    s.erase(s.begin());
    d = 0;
    return;
  }
  auto it = s.find(make_pair(tin[v], v));
  auto l = prev(it == s.begin() ? s.end() : it);
  auto r = (it == --s.end() ? s.begin() : next(it));
  d -= get_dist(l->second, it->second);
  d -= get_dist(it->second, r->second);
  d += get_dist(l->second, r->second);
  s.erase(it);
}
int main() {
  n = nextInt<int>();
  k = nextInt<int>();
  for (int i = 0; i < n - 1; ++i) {
    int x = nextInt<int>();
    int y = nextInt<int>();
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1);
  int best = 0;
  int l = 1;
  for (int r = 1; r <= n; ++r) {
    append(r);
    while (calc() > k) {
      extract(l++);
    }
    best = max(best, r - l + 1);
  }
  printf("%d\n", best);
  return 0;
}
