#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=200010;
const int inf=2147483647;
const double pi=acos(-1.0);
LL read()
{
	LL x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=x*10ll+ch-'0',ch=getchar();
	return x*f;
}
int n,k,f[Maxn],g[Maxn],w;
vector<int>G[Maxn];
void dfs(int x,int fa)
{
	f[x]=0;
	int mx=0,mn=0;bool flag=false;
	for(int i=0;i<G[x].size();i++)
	{
		int y=G[x][i];
		if(y==fa)continue;flag=true;
		dfs(y,x);f[x]+=f[y];
		int t=g[y];
		if(t>0)mx=max(mx,t);
		else mn=min(mn,t);
	}
	if(!flag){g[x]=-1;return;}
	if(mx-1+mn>=0&&mx)g[x]=mx-1;
	else
	{
		if(mn==-w)
		{
//			printf("# %d\n",x);
			f[x]++;
			g[x]=w;
		}
		else g[x]=mn-1;
	}
//	printf("%d %d %d\n",x,f[x],g[x]);
}
bool check()
{
	dfs(1,0);
	return(f[1]+(g[1]<0)<=k);
}
int main()
{
	n=read(),k=read();
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		G[x].push_back(y),G[y].push_back(x);
	}
//	w=1;check();return 0;
	int l=1,r=n-1;
	while(l<=r)
	{
		int mid=l+r>>1;w=mid;
		if(check())r=mid-1;
		else l=mid+1; 
	}
	printf("%d",r+1);
}
#include<bits/stdc++.h>
#define ln puts("")
using namespace std;
typedef long long ll;

inline ll read() {
	ll sum = 0, ff = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9') {
		if(ch == '-')
			ff = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9')
		sum = sum * 10 + ch - '0', ch = getchar();
	return sum * ff;
}

const int N = 2007;
int n, m;
ll ans;
struct edge {
	int to, nxt;
}e[N];
int cnt, he[N];
bool vis[N];

void add(int u, int v) {
	e[++cnt].to = v;
	e[cnt].nxt = he[u];
	he[u] = cnt;
}

void dfs(int u) {
	ans++;
	vis[u] = true;
	for(int i = he[u]; i; i = e[i].nxt) {
		int v = e[i].to;
		if(vis[v])
			continue;
		dfs(v);
	}
}

int main() {
//	freopen("", "r", stdin);
//	freopen("", "w", stdout);
	n = read(), m = read();
	for(int i = 1; i <= m; i++) {
		int u = read(), v = read();
		add(u, v);
	}
	for(int i = 1; i <= n; i++) {
		memset(vis, false, sizeof(vis));
		dfs(i);
	}
	cout << ans;
	return 0;
}
