/*
* Copyright (c) 2024 Emon Thakur
* All rights reserved.
*/
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
vector<int> g[200005];
int height[200005] , dp[101][200005];
int n,k;
#define fr freopen("input19.txt","r",stdin);
ofstream file("output19.txt");
void dfs(int node,int par)
{
height[node] = 0;
for(int e:g[node])
{
if(e==par) continue;
dfs(e,node);
}
int mx = 0;
for(int e:g[node])
{
if(e==par) continue;
mx = max(mx , height[e]);
}
height[node] = mx+1;
}
void dpontree(int node,int par)
{
int mxh=0,mxh2=0;
for(auto e:g[node])
{
if(e==par) continue;
if(height[e] >= mxh)
{
mxh2 = mxh;
mxh = height[e];
}
else if(height[e] > mxh2) mxh2 = height[e];
}
for(auto e:g[node])
{
if(e==par) continue;
dpontree(e,node);
}
for(int i=0;i<=k;i++)
{
dp[i][node] = 1;
for(auto e:g[node])
{
if(e==par) continue;
if(height[e] == mxh)
{
dp[i][node] = max(dp[i][node] , min(mxh2,i) + dp[max(0,i-mxh2)][e] + 1);
}
else
{
dp[i][node] = max(dp[i][node] , min(mxh,i) + dp[max(0,i-mxh)][e] + 1);
}
}
}
}
int main()
{
ios::sync_with_stdio(false); cin.tie(nullptr);
//fr
cin >> n >> k;
for(int i=0;i<n-1;i++)
{
int u,v; cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
dfs(1,0);
//for(int i=1;i<=n;i++) cout<<i<<" "<<height[i]<<endl;
dpontree(1,0);
cout << dp[k][1] << endl;
//file<<dp[k][1]<<endl;
//for(int i=0;i<=k;i++) cout<<i<<" "<<dp[i][1]<<endl;
}