#include <bits/stdc++.h>

using namespace std;

const int N = int(1e5)+10;
const int LOGN = 20;
const int INF = int(1e9);
set<int> g[N];
int par[N],sub[N],level[N],ans[N];
int centroidlevel[N];
int DP[LOGN][N];
int n,m;
/*Using centroid Decomposition of a tree */

vector<int> child_dist[N];
vector< vector<int> > inside_child_dist[N];
int cidx[N],depth[N];
vector< pair<int,int> > edges;

/*----------- Pre-Processing ------------*/
void dfs0(int u)
{
	for(auto it=g[u].begin();it!=g[u].end();it++)
		if(*it!=DP[0][u])
		{
			DP[0][*it]=u;
			level[*it]=level[u]+1;
			dfs0(*it);
		}
}
void preprocess()
{
	level[0]=0;
	DP[0][0]=0;
	dfs0(0);
	for(int i=1;i<LOGN;i++)
		for(int j=0;j<n;j++)
			DP[i][j] = DP[i-1][DP[i-1][j]];
}
int lca(int a,int b)
{
	if(level[a]>level[b])swap(a,b);
	int d = level[b]-level[a];
	for(int i=0;i<LOGN;i++)
		if(d&(1<<i))
			b=DP[i][b];
	if(a==b)return a;
	for(int i=LOGN-1;i>=0;i--)
		if(DP[i][a]!=DP[i][b])
			a=DP[i][a],b=DP[i][b];
	return DP[0][a];
}
int dist(int u,int v)
{
	return level[u] + level[v] - 2*level[lca(u,v)];
}
/*-----------------Decomposition Part--------------------------*/
int nn;
void dfs1(int u,int p)
{
	sub[u]=1;
	nn++;
	for(auto it=g[u].begin();it!=g[u].end();it++)
		if(*it!=p)
		{
			dfs1(*it,u);
			sub[u]+=sub[*it];
		}
}
int dfs2(int u,int p)
{
	for(auto it=g[u].begin();it!=g[u].end();it++)
		if(*it!=p && sub[*it]>nn/2)
			return dfs2(*it,u);
	return u;
}
void dfs3(int v, int p, int centroid, int idx, int curd) {
	child_dist[centroid].push_back(curd);
	inside_child_dist[centroid][idx].push_back(curd);
	for (int x : g[v]) if (x != p) {
		dfs3(x,v,centroid,idx,curd+1);
	}
}

void decompose(int root,int p,int thidx,int dpth)
{
	nn=0;
	dfs1(root,root);
	int centroid = dfs2(root,root);
	if(p==-1)p=centroid;

	par[centroid]=p;
	depth[centroid]=dpth;
	cidx[centroid]=thidx;

	int idx = 0;
	inside_child_dist[centroid].resize(g[centroid].size());
	for(auto it=g[centroid].begin();it!=g[centroid].end();it++)
	{
		g[*it].erase(centroid);
		dfs3(*it, centroid, centroid, idx, 1);
		decompose(*it,centroid,idx,dpth+1);
		sort(inside_child_dist[centroid][idx].begin(), inside_child_dist[centroid][idx].end());
		idx++;
	}
	child_dist[centroid].push_back(0);
	sort(child_dist[centroid].begin(), child_dist[centroid].end());
	g[centroid].clear();
}
/*----------------- Handle the Queries -----------------*/

int k;

int getK(const vector<int>& v, int maxvalue ) {
	return upper_bound(v.begin(), v.end(), maxvalue) - v.begin();
}

int query(int u)
{
	int x = u;
	int ans = getK(child_dist[x], k/2);
	while(par[x] != x)
	{
		int mydist = dist(par[x], u);
		ans += getK(child_dist[ par[x] ], k/2 - mydist) - getK(inside_child_dist[ par[x] ][ cidx[x] ], k/2 - mydist);
		x = par[x];
	}
	return ans;
}

int queryDual(int u, int v) {
	if (depth[u] < depth[v]) swap(u,v);
	int x = u;
	int ans = getK(child_dist[x], (k-1)/2);
	while(par[x] != x)
	{
		int mydist = min(dist(par[x], u), dist(par[x], v));
		ans += getK(child_dist[ par[x] ], (k-1)/2 - mydist) - getK(inside_child_dist[ par[x] ][ cidx[x] ], (k-1)/2 - mydist);
		x = par[x];
	}
	return ans;
}

int main()
{
	scanf("%d %d",&n,&k);
	for(int i=0;i<n-1;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		g[u-1].insert(v-1);
		g[v-1].insert(u-1);
		edges.push_back({u-1,v-1});
	}
	preprocess();
	decompose(0,-1,0,0);
	int ans = 0;
	for(int i=0;i<n;i++) {
		ans = max(ans, query(i));
	}

	for ( pair<int,int> p : edges) {
		ans = max(ans, queryDual(p.first, p.second));
	}

	printf("%d\n", n-ans);
	return 0;
}

Measured memory_bytes: 10368