#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define N 2005
using namespace std;
typedef long long ll;
int n,k,a,b,tot,Maxde,deep[N],sum,ans=0x7fffffff;
int head[N],to[N<<1],nex[N<<1],fa[N],de[N];
int leaves[N],tmp;
void add(int x,int y)
{
	to[++tot]=y;
	nex[tot]=head[x];
	head[x]=tot;
}
void dfs1(int x,int fath)  //O(n)
{
	fa[x]=fath;
	de[x]=de[fath]+1;
	deep[de[x]]++;
	Maxde=max(Maxde,de[x]);
	for(int i=head[x];i;i=nex[i])
	{
		if(to[i]==fath) continue;
		dfs1(to[i],x);
	}
}
void dfs2(int x,int fath)
{
	bool flag=0;
	for(int i=head[x];i;i=nex[i])
	{
		if(to[i]==fath) continue;
		else flag=1;
		dfs2(to[i],x);
	}
	if(!flag) leaves[++tmp]=x;;
}
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n-1;i++)
	{
		scanf("%d %d",&a,&b);
		add(a,b);add(b,a);
	}
	dfs2(1,0);
	for(int i=1;i<=tmp;i++)
	{
		memset(deep,0,sizeof(deep));
		dfs1(i,0); sum=0;
		for(int j=k+1;j<=Maxde;j++)
		{
			sum+=deep[j];
		}
		ans=min(ans,sum);
	}
	printf("%d",ans);
	return 0;
}
