#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=2000+10;
int h[maxn],go[maxn*2],nxt[maxn*2],f[maxn][maxn],g[maxn],dep[maxn];
int i,j,k,l,t,n,m,tot,top,ans;
void add(int x,int y){
	go[++tot]=y;
	nxt[tot]=h[x];
	h[x]=tot;
}
void dfs(int x,int y){
	f[x][0]=1;
	dep[x]=0;
	int t=h[x],i,j;
	while (t){
		if (go[t]!=y){
			dfs(go[t],x);
			fo(i,0,m) g[i]=f[x][i];
			fo(i,0,dep[x])
				fo(j,0,dep[go[t]])
					if (i+j+1<=m) g[max(i,j+1)]=max(g[max(i,j+1)],f[x][i]+f[go[t]][j]);
			dep[x]=max(dep[x],dep[go[t]]+1);
			fo(i,0,m) f[x][i]=g[i];
		}
		t=nxt[t];
	}
	fo(i,0,m) ans=max(ans,f[x][i]);
}
int main(){
	scanf("%d%d",&n,&m);
	if (m==0){
		printf("%d\n",n-1);
		return 0;
	}
	fo(i,1,n-1){
		scanf("%d%d",&j,&k);
		add(j,k);add(k,j);
	}
	fo(i,0,n)
		fo(j,0,n)
			f[i][j]=-n;
	dfs(1,0);
	ans=n-ans;
	printf("%d\n",ans);
}