#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100100];
int pai[17][100100];
int h[100100], ini[100100], fim[100100];
int bit[100100];
void add(int p, int v) {
  for (; p < 100100; p += (p & (-p))) bit[p] += v;
}
int get(int p) {
  int s = 0;
  for (; p; p -= (p & (-p))) s += bit[p];
  return s;
}
int sum(int v) { return get(fim[v]) - get(ini[v] - 1); }
int cnt;
void calc(int v, int p, int hh) {
  h[v] = hh;
  pai[0][v] = p;
  ini[v] = cnt;
  for (int i = 0; i < adj[v].size(); i++) {
    int w = adj[v][i];
    if (w == p) continue;
    calc(w, v, hh + 1);
  }
  fim[v] = cnt++;
}
int lca(int a, int b) {
  if (h[b] > h[a]) swap(a, b);
  for (int k = 17 - 1; k >= 0; k--)
    if (h[a] - h[b] >= (1 << k)) a = pai[k][a];
  if (a == b) return a;
  for (int k = 17 - 1; k >= 0; k--)
    if (pai[k][a] != pai[k][b]) a = pai[k][a], b = pai[k][b];
  return pai[0][a];
}
int paih(int v, int q) {
  for (int k = 17 - 1; k >= 0; k--)
    if (q >= (1 << k)) v = pai[k][v], q -= (1 << k);
  return v;
}
int func(int conf, int tot) {
  int l1 = 0, l2 = h[conf];
  while (l1 < l2) {
    int w = (l1 + l2) / 2;
    int pp = paih(conf, w);
    if (sum(pp) < tot)
      l1 = w + 1;
    else
      l2 = w;
  }
  return paih(conf, l2);
}
int n, k;
int custo(int v, int conf, int tot) {
  int no = func(conf, tot);
  if (sum(v) > 0 && h[no] <= h[v]) return 0;
  int lc = lca(no, v);
  if (lc != no) return h[no] + h[v] - 2 * h[lc];
  return h[v] - h[func(v, 1)];
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    adj[a].push_back(b), adj[b].push_back(a);
  }
  cnt = 1;
  calc(1, 0, 0);
  for (int i = 1; i < 17; i++)
    for (int j = 1; j < n + 1; j++) pai[i][j] = pai[i - 1][pai[i - 1][j]];
  int cus = 1;
  int p = 1;
  int rsp = 1;
  add(fim[1], 1);
  for (int i = 2; i < n + 1; i++) {
    cus += custo(i, i - 1, i - p);
    add(fim[i], 1);
    while (cus > k) {
      add(fim[p], -1);
      if (i - p == 1)
        cus = 1;
      else
        cus -= custo(p, i - 1, i - p);
      p++;
    }
    rsp = max(rsp, i - p + 1);
  }
  printf("%d\n", rsp);
  return 0;
}
