#include <bits/stdc++.h>
using namespace std;
const int NMax = 100005;
vector<int> G[NMax], V[NMax];
int N, M;
int Level[NMax];
int Log[NMax], cnt;
int Father[20][NMax];
int Line[NMax * 5];
int First[NMax];
set<int> S;
int sz;
void Read() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i < N; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
}
void DFS(int node, int father) {
  Father[0][node] = father;
  Level[node] = Level[father] + 1;
  First[node] = ++cnt;
  Line[cnt] = node;
  V[node].push_back(cnt);
  for (int i = 0; i < G[node].size(); i++) {
    int neighb = G[node][i];
    if (neighb == father) continue;
    DFS(neighb, node);
    V[node].push_back(++cnt);
    Line[cnt] = node;
  }
}
void precalcFather() {
  for (int i = 1; (1 << i) <= N; i++)
    for (int j = 1; j <= N; j++) Father[i][j] = Father[i - 1][Father[i - 1][j]];
}
void precalcLog() {
  for (int i = 2; i <= N; i++) Log[i] = Log[i / 2] + 1;
}
int F(int x, int dist) {
  while (dist > 0) {
    int k = Log[dist];
    x = Father[k][x];
    dist -= (1 << k);
  }
  return x;
}
int LCA(int x, int y) {
  if (Level[x] < Level[y]) swap(x, y);
  x = F(x, Level[x] - Level[y]);
  if (x == y) return x;
  for (int i = Log[N]; i >= 0; i--) {
    if (Father[i][x] != Father[i][y]) {
      x = Father[i][x];
      y = Father[i][y];
    }
  }
  return Father[0][x];
}
int mod(int x) { return max(x, -x); }
int Dist(int x, int y) {
  int lca = LCA(x, y);
  return Level[x] - Level[lca] + Level[y] - Level[lca];
}
void Solve() {
  int i = 1, j = 1;
  int ans = 1, curr = 1;
  for (int k = 0; k < V[1].size(); k++) S.insert(V[1][k]);
  while (i <= N) {
    ++j;
    while (j <= N) {
      if (S.empty()) {
        for (int k = 0; k < V[j].size(); k++) S.insert(V[j][k]);
        ++j;
        sz = 0;
        continue;
      }
      auto it = S.lower_bound(First[j]);
      auto it2 = it;
      if (it2 != S.begin()) {
        it2 = prev(it2);
        if (it == S.end()) it = S.begin();
      } else {
        it = prev(S.end());
      }
      int poz = First[j], s = Line[*it], u = Line[*it2];
      if ((sz + (Dist(j, s) + Dist(u, j) - Dist(s, u)) / 2) < M) {
        ans = max(ans, j - i + 1);
        sz += (Dist(j, s) + Dist(u, j) - Dist(s, u)) / 2;
      } else
        break;
      for (int k = 0; k < V[j].size(); k++) S.insert(V[j][k]);
      ++j;
    }
    --j;
    for (int k = 0; k < V[i].size(); k++) S.erase(V[i][k]);
    if (S.empty()) {
      sz = 0;
      ++i;
      continue;
    }
    auto it = S.lower_bound(First[i]);
    auto it2 = it;
    if (it2 != S.begin()) {
      it2 = prev(it2);
      if (it == S.end()) it = S.begin();
    } else {
      it = prev(S.end());
    }
    int poz = First[i], s = Line[*it], u = Line[*it2];
    sz -= (Dist(i, s) + Dist(u, i) - Dist(s, u)) / 2;
    ++i;
  }
  printf("%d\n", ans);
}
int main() {
  Read();
  DFS(1, 0);
  precalcLog();
  precalcFather();
  Solve();
  return 0;
}
