#include <bits/stdc++.h>
using namespace std;
const int T = 1e5 + 10;
int timer = 1, SUL, n, k;
int D[T][20];
int out[T], in[T], deg[T];
vector<int> g[T];
set<pair<int, int> > s;
void read() {
  scanf("%d %d", &n, &k);
  int i;
  for (i = 1; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
}
void go(int v, int p) {
  D[v][0] = p;
  for (int i = 1; i < 20; i++) D[v][i] = D[D[v][i - 1]][i - 1];
  deg[v] = deg[p] + 1;
  in[v] = timer++;
  for (vector<int>::iterator it = g[v].begin(); it != g[v].end(); it++) {
    if (*it == p) continue;
    go(*it, v);
  }
  out[v] = timer++;
}
bool upper(int a, int b) {
  if (a == 0 || b == 0) return 1;
  return (in[a] <= in[b] && out[a] >= out[b]);
}
int LCA(int a, int b) {
  if (upper(a, b)) return a;
  if (upper(b, a)) return b;
  for (int i = 19; i >= 0; i--) {
    if (!upper(D[a][i], b)) a = D[a][i];
  }
  return D[a][0];
}
int dist(int a, int b) {
  int c = LCA(a, b);
  return deg[a] + deg[b] - deg[c] * 2;
}
void preProcess() { go(1, 0); }
set<pair<int, int> >::iterator L(set<pair<int, int> >::iterator it) {
  if (it == s.begin()) {
    it = s.end();
    it--;
    return it;
  }
  it--;
  return it;
}
set<pair<int, int> >::iterator R(set<pair<int, int> >::iterator it) {
  it++;
  if (it == s.end()) return s.begin();
  return it;
}
bool add_in(int v) {
  s.insert(make_pair(in[v], v));
  if (s.size() == 1) {
    SUL = 0;
    return 1;
  }
  if (s.size() == 2) {
    SUL = 2 * (dist(s.begin()->second, (s.rbegin())->second));
    return SUL / 2 + 1 <= k;
  }
  set<pair<int, int> >::iterator it;
  it = s.find(make_pair(in[v], v));
  set<pair<int, int> >::iterator itL = L(it);
  set<pair<int, int> >::iterator itR = R(it);
  SUL -= dist(itL->second, itR->second);
  SUL += dist(it->second, itR->second);
  SUL += dist(itL->second, it->second);
  return (SUL / 2 + 1 <= k);
}
void pop_out(int v) {
  set<pair<int, int> >::iterator it;
  if (s.size() <= 3) {
    s.erase(make_pair(in[v], v));
    SUL = 0;
    if (s.size() == 1) {
      SUL = 0;
    }
    if (s.size() == 2) {
      SUL = 2 * (dist(s.begin()->second, (s.rbegin())->second));
    }
    return;
  }
  it = s.find(make_pair(in[v], v));
  set<pair<int, int> >::iterator itL = L(it);
  set<pair<int, int> >::iterator itR = R(it);
  SUL += dist(itL->second, itR->second);
  SUL -= dist(it->second, itR->second);
  SUL -= dist(itL->second, it->second);
  s.erase(make_pair(in[v], v));
}
int solve() {
  int pos = 0;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i > 1) pop_out(i - 1);
    while (pos + 1 <= n && add_in(pos + 1)) pos++;
    if (pos + 1 <= n) pop_out(pos + 1);
    ans = max(ans, pos - i + 1);
  }
  return ans;
}
int main() {
  read();
  preProcess();
  printf("%d\n", solve());
}
