#include <bits/stdc++.h>
using namespace std;
int t[100100], root = 1;
vector<int> v[100100];
void add(int k, int v) {
  while (k < 100100) t[k] += v, k += k & -k;
}
int sum(int k, int s = 0) {
  while (k) s += t[k], k -= k & -k;
  return s;
}
int n, K, tot, dep[100100], dis[100100], fin[100100];
int pa[100100][20];
int I = 1, J = 1;
int answer = 1, current = 1;
void dfs(int u, int fa) {
  dis[u] = ++tot;
  pa[u][0] = fa;
  dep[u] = dep[fa] + 1;
  for (int i = 0; i < v[u].size(); i++) {
    int j = v[u][i];
    if (j != fa) dfs(j, u);
  }
  fin[u] = tot;
}
void init() {
  scanf("%d %d", &n, &K);
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    v[a].push_back(b), v[b].push_back(a);
  }
  dfs(1, 0);
  for (int j = 1; j < 20; j++)
    for (int i = 1; i <= n; i++) {
      pa[i][j] = pa[pa[i][j - 1]][j - 1];
    }
}
int common_ans(int a, int b) {
  if (dep[a] < dep[b]) swap(a, b);
  int d = dep[a] - dep[b];
  for (int i = 19; i >= 0; i--)
    if (d >= (1 << i)) {
      d -= 1 << i;
      a = pa[a][i];
    }
  if (a == b) return a;
  for (int i = 19; i >= 0; i--) {
    if (pa[a][i] != pa[b][i]) a = pa[a][i], b = pa[b][i];
  }
  return pa[a][0];
}
bool intree(int z) { return sum(fin[z]) > sum(dis[z] - 1); }
int calc(int st, int en, int z) {
  int ans = 0;
  if (intree(z)) {
    if (intree(st)) return 0;
    for (int i = 19; i >= 0; i--)
      if (dep[st] - dep[z] > (1 << i)) {
        int mid = pa[st][i];
        if (intree(mid))
          z = mid;
        else
          ans += (1 << i), st = mid;
      }
    return ans + 1;
  } else {
    ans = dep[en] + dep[st] - 2 * dep[z];
    for (int i = 19; i >= 0; i--)
      if (dep[en] - dep[z] > (1 << i)) {
        int mid = pa[en][i];
        if (intree(mid))
          en = mid, ans -= (1 << i);
        else
          z = mid;
      }
    return ans;
  }
}
int Insert(int st, int en) {
  int z = common_ans(st, en);
  current += calc(en, st, z);
  add(dis[st], 1);
  add(dis[en], 1);
  add(dis[z], -1);
  if (z != root) add(dis[pa[z][0]], -1);
}
int Delete(int st, int en) {
  int z = common_ans(st, en);
  add(dis[st], -1);
  add(dis[en], -1);
  add(dis[z], 1);
  if (z != root) add(dis[pa[z][0]], 1);
  current -= calc(st, en, z);
}
void solve() {
  int cnt = 0;
  while (J < n) {
    while (I < J && current > K) {
      Delete(I, I + 1);
      I++;
    }
    while (J < n && current <= K) {
      Insert(J, J + 1);
      J++;
    }
    if (current <= K)
      answer = (answer > J - I + 1 ? answer : J - I + 1);
    else
      answer = (answer > J - I ? answer : J - I);
  }
  printf("%d\n", answer);
}
int main() {
  init();
  if (K == 1) {
    puts("1");
    return 0;
  }
  if (K == n) {
    printf("%d\n", n);
    return 0;
  }
  solve();
  return 0;
}
