#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n, m;
vector<int> edge[200000];
int walk[300000];
int walki;
int wh[300000];
int S = 262144;
int itree[600000];
int level[200000];
set<int> a;
int jums;
void update(int now) {
  now /= 2;
  while (now > 0) {
    itree[now] = min(itree[now * 2], itree[now * 2 + 1]);
    now /= 2;
  }
}
int getmin(int x, int y) {
  int minn = INT_MAX;
  while (x <= y) {
    if (x % 2 == 1) minn = min(minn, itree[x]), x++;
    if (y % 2 == 0) minn = min(minn, itree[y]), y--;
    x /= 2, y /= 2;
  }
  return minn;
}
void dfs(int now, int parent) {
  int i, j;
  walk[walki++] = now;
  wh[now] = walki - 1;
  level[now] = (parent == -1) ? 0 : level[parent] + 1;
  for (i = 0; i < edge[now].size(); i++) {
    if (edge[now][i] == parent) continue;
    dfs(edge[now][i], now);
    walk[walki++] = now;
  }
}
int getdis(int x, int y) {
  if (wh[x] > wh[y]) swap(x, y);
  int lca = getmin(S + wh[x], S + wh[y]);
  return (level[x] - lca) + (level[y] - lca);
}
int cost(int now) {
  if (a.size() == 0) return 1;
  int dis;
  set<int>::iterator l = a.lower_bound(wh[now]);
  set<int>::iterator r = l--;
  if (r == a.begin() || r == a.end()) {
    l = a.begin();
    r = a.end(), r--;
  }
  dis = getdis(now, walk[*l]) + getdis(now, walk[*r]) -
        getdis(walk[*l], walk[*r]);
  dis /= 2;
  return dis;
}
int add(int now) {
  int dis;
  if (now == n) return 0;
  if (a.size() == 0) {
    a.insert(wh[now]);
    jums++;
    return 1;
  }
  dis = cost(now);
  if (jums + dis > m) {
    return 0;
  } else {
    a.insert(wh[now]);
    jums += dis;
    return 1;
  }
}
void del(int now) {
  a.erase(wh[now]);
  jums -= cost(now);
}
int main() {
  int i, j, k;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  dfs(0, -1);
  for (i = 0; i < walki; i++) {
    itree[S + i] = level[walk[i]];
    update(S + i);
  }
  int st, en = 0;
  int max = 0;
  for (st = 0; st < n; st++) {
    while (add(en)) {
      en++;
    }
    if (max < en - st) {
      max = en - st;
    }
    del(st);
  }
  printf("%d", max);
  return 0;
}
