#include <bits/stdc++.h>
using namespace std;
template <typename input_type>
input_type get() {
  input_type input;
  cin >> input;
  return input;
}
const int max_size = (1e5 + 5), max_num = 2e1;
int size, max_sum, out, dfn[max_size], idfn[max_size], ans, tm, lvl[max_size],
    fa[max_size][max_num];
vector<int> v[max_size];
set<int> st;
void dfs(int np, int fath) {
  dfn[np] = ++tm;
  idfn[tm] = np;
  lvl[np] = (lvl[fath] + 1);
  fa[np][0] = fath;
  for (int i = 1; i < 18; i++) {
    fa[np][i] = fa[fa[np][i - 1]][i - 1];
  }
  for (int x : v[np]) {
    if (x != fath) {
      dfs(x, np);
    }
  }
}
int lca(int x, int y) {
  if (lvl[x] < lvl[y]) {
    swap(x, y);
  }
  for (int i = (max_num - 1); i >= 0; i--) {
    if (lvl[fa[x][i]] >= lvl[y]) {
      x = fa[x][i];
    }
  }
  if (x == y) {
    return x;
  }
  for (int i = (max_num - 1); i >= 0; i--) {
    if (fa[x][i] != fa[y][i]) {
      x = fa[x][i];
      y = fa[y][i];
    }
  }
  return fa[x][0];
}
int dis(int x, int y) { return (lvl[x] + lvl[y] - (2 * lvl[lca(x, y)])); }
void insert(int x) {
  set<int>::iterator pre, nxt;
  pre = nxt = st.lower_bound(x);
  if (nxt != st.end()) {
    ans += dis(idfn[*nxt], idfn[x]);
  }
  if (pre != st.begin()) {
    pre--;
    if (nxt != st.end()) {
      ans -= dis(idfn[*pre], idfn[*nxt]);
    }
    ans += dis(idfn[*pre], idfn[x]);
  }
  st.insert(x);
}
void del(int x) {
  set<int>::iterator pre, nxt;
  pre = nxt = st.find(x);
  nxt++;
  if (nxt != st.end()) {
    ans -= dis(idfn[*nxt], idfn[x]);
  }
  if (pre != st.begin()) {
    pre--;
    if (nxt != st.end()) {
      ans += dis(idfn[*pre], idfn[*nxt]);
    }
    ans -= dis(idfn[*pre], idfn[x]);
  }
  st.erase(x);
}
int main() {
  size = get<int>(), max_sum = get<int>();
  for (int i = 1; i < size; i++) {
    pair<int, int> endpnt = {get<int>(), get<int>()};
    v[endpnt.first].push_back(endpnt.second);
    v[endpnt.second].push_back(endpnt.first);
  }
  dfs(1, 0);
  for (int i = 1, j = 1; i <= size; i++) {
    insert(dfn[i]);
    while ((((ans + dis(idfn[*st.begin()], idfn[*st.rbegin()])) >> 1) + 1) >
           max_sum) {
      del(dfn[j]);
      j++;
    }
    out = max(out, ((i - j) + 1));
  }
  cout << out << '\n';
  return 0;
}
