#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
const int MAXLog = 20;
int g[MAXN], g_lnk[MAXN * 2], g_nxt[MAXN * 2];
int n, limit;
int dep[MAXN];
int up[MAXN][MAXLog];
int size[MAXN], fa[MAXN];
int belong[MAXN], ind[MAXN];
int tr_head[MAXN], tr_len[MAXN], tr_st[MAXN];
int tr_num;
void dfs(int x, int f) {
  fa[x] = f;
  size[x] = 1;
  up[x][0] = f;
  dep[x] = dep[f] + 1;
  for (int i = 0; up[x][i] > 0; ++i) up[x][i + 1] = up[up[x][i]][i];
  int my = 0, msize = 0;
  for (int i = g[x]; i > 0; i = g_nxt[i]) {
    int y = g_lnk[i];
    if (y == f) continue;
    dfs(y, x);
    if (size[y] > msize) {
      msize = size[y];
      my = y;
    }
    size[x] += size[y];
  }
  if (my > 0) {
    belong[x] = belong[my];
    ind[x] = ++tr_len[belong[x]];
    tr_head[belong[x]] = x;
  } else {
    belong[x] = ++tr_num;
    ind[x] = 1;
    tr_head[tr_num] = x;
    tr_len[tr_num] = 1;
  }
}
struct Node {
  int min_val, num;
  friend Node operator+(Node a, Node b) {
    if (a.min_val < b.min_val) return a;
    if (b.min_val < a.min_val) return b;
    a.num += b.num;
    return a;
  }
} tr[MAXN * 4];
int tr_buf[MAXN * 4];
int len, cur;
void tr_build(int x, int s, int t) {
  tr_buf[x] = 0;
  tr[x].min_val = 0;
  tr[x].num = t - s + 1;
  if (s == t) return;
  int mid = (s + t) / 2;
  tr_build(x * 2, s, mid);
  tr_build(x * 2 + 1, mid + 1, t);
}
void tr_add(int x, int s, int t, int st, int en, int val) {
  if (st <= s && t <= en) {
    tr[x].min_val += val;
    tr_buf[x] += val;
    return;
  }
  if (tr_buf[x] != 0) {
    tr[x * 2].min_val += tr_buf[x];
    tr_buf[x * 2] += tr_buf[x];
    tr[x * 2 + 1].min_val += tr_buf[x];
    tr_buf[x * 2 + 1] += tr_buf[x];
    tr_buf[x] = 0;
  }
  int mid = (s + t) / 2;
  if (st <= mid) tr_add(x * 2, s, mid, st, en, val);
  if (mid < en) tr_add(x * 2 + 1, mid + 1, t, st, en, val);
  tr[x] = tr[x * 2] + tr[x * 2 + 1];
}
void add(int x, int val) {
  while (x > 0) {
    int t = belong[x];
    int y = tr_head[t];
    tr_add(1, 1, len, tr_st[t] + ind[x], tr_st[t] + ind[y], val);
    x = fa[y];
  }
}
int count_zero() {
  if (tr[1].min_val == 0)
    return tr[1].num;
  else
    return 0;
}
int u[MAXN * 4];
int lca(int a, int b) {
  for (int i = MAXLog - 1; i >= 0; --i) {
    if (dep[up[a][i]] >= dep[b]) a = up[a][i];
    if (dep[up[b][i]] >= dep[a]) b = up[b][i];
  }
  for (int i = MAXLog - 1; i >= 0; --i)
    if (up[a][i] != up[b][i]) a = up[a][i], b = up[b][i];
  if (a != b) a = up[a][0];
  return a;
}
int u_get(int x, int s, int t, int st, int en) {
  if (st <= s && t <= en) return u[x];
  int mid = (s + t) / 2;
  if (en <= mid) return u_get(x * 2, s, mid, st, en);
  if (mid < st) return u_get(x * 2 + 1, mid + 1, t, st, en);
  int p = u_get(x * 2, s, mid, st, en);
  int q = u_get(x * 2 + 1, mid + 1, t, st, en);
  return lca(p, q);
}
void u_build(int x, int s, int t) {
  if (s == t) {
    u[x] = s;
    return;
  }
  int mid = (s + t) / 2;
  u_build(x * 2, s, mid);
  u_build(x * 2 + 1, mid + 1, t);
  u[x] = lca(u[x * 2], u[x * 2 + 1]);
}
int main() {
  scanf("%d%d", &n, &limit);
  int e = 0;
  for (int i = int(1); i <= int(n - 1); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    g_lnk[++e] = b, g_nxt[e] = g[a], g[a] = e;
    g_lnk[++e] = a, g_nxt[e] = g[b], g[b] = e;
  }
  tr_num = 0;
  memset(up, 0, sizeof(up));
  dep[0] = 0;
  dfs(1, 0);
  len = 0;
  for (int i = int(1); i <= int(tr_num); ++i) {
    tr_st[i] = len;
    len += tr_len[i];
  }
  tr_build(1, 1, len);
  u_build(1, 1, n);
  int ans = 0;
  int le = 1;
  for (int ri = int(1); ri <= int(n); ++ri) {
    add(ri, 1);
    while (1) {
      int cnt = n - count_zero();
      int z = u_get(1, 1, n, le, ri);
      cnt -= dep[z] - 1;
      if (cnt <= limit) break;
      add(le, -1);
      ++le;
    }
    ans = max(ans, ri - le + 1);
  }
  printf("%d\n", ans);
  return 0;
}
