// Shaazzz
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, k, H[N];
vector < int > Adj[N];
void DFS(int v, int p)
{
for (int &u : Adj[v])
if (u != p)
H[u] = H[v] + 1,
DFS(u, v);
}
int main()
{
scanf("%d%d", &n, &k);
for (int i = 1; i < n; i++)
{
int v, u;
scanf("%d%d", &v, &u);
Adj[v].push_back(u);
Adj[u].push_back(v);
}
DFS(1, 0);
int v = 0, d = 0;
for (int i = 1; i <= n; i++)
if (H[i] >= H[v])
v = i;
H[v] = 0; DFS(v, 0);
for (int i = 1; i <= n; i++)
d = max(d, H[i]);
if (k <= d) return !printf("%d", k + 1);
return !printf("%d", min((k + d + 2) / 2, n));
}
Ly8gU2hhYXp6egojaW5jbHVkZTxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjb25zdCBpbnQgTiA9IDFlNiArIDEwOwppbnQgbiwgaywgSFtOXTsKdmVjdG9yIDwgaW50ID4gQWRqW05dOwp2b2lkIERGUyhpbnQgdiwgaW50IHApCnsKICAgIGZvciAoaW50ICZ1IDogQWRqW3ZdKQogICAgICAgIGlmICh1ICE9IHApCiAgICAgICAgICAgIEhbdV0gPSBIW3ZdICsgMSwKICAgICAgICAgICAgREZTKHUsIHYpOwp9CmludCBtYWluKCkKewogICAgc2NhbmYoIiVkJWQiLCAmbiwgJmspOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPCBuOyBpKyspCiAgICB7CiAgICAgICAgaW50IHYsIHU7CiAgICAgICAgc2NhbmYoIiVkJWQiLCAmdiwgJnUpOwogICAgICAgIEFkalt2XS5wdXNoX2JhY2sodSk7CiAgICAgICAgQWRqW3VdLnB1c2hfYmFjayh2KTsKICAgIH0KICAgIERGUygxLCAwKTsKICAgIGludCB2ID0gMCwgZCA9IDA7CiAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspCiAgICAgICAgaWYgKEhbaV0gPj0gSFt2XSkKICAgICAgICAgICAgdiA9IGk7CiAgICBIW3ZdID0gMDsgREZTKHYsIDApOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKQogICAgICAgIGQgPSBtYXgoZCwgSFtpXSk7CiAgICBpZiAoayA8PSBkKSByZXR1cm4gIXByaW50ZigiJWQiLCBrICsgMSk7CiAgICByZXR1cm4gIXByaW50ZigiJWQiLCBtaW4oKGsgKyBkICsgMikgLyAyLCBuKSk7Cn0=