#include <bits/stdc++.h>
using namespace std;

const int N = 2000 + 5;
int v, u, n, k, ans = 1e7;
vector<int> adj_matrix[N];

void dfs(int v, int p){
	dis[v] = dis[p] + 1;
	mark[v] = true;
	for (int i = 0; i < adj_matrix[v].size(); i++){
		int u = adj_matrix[v][i];
		if(u != p)
			dfs(u, v);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0)

	cin >> n >> k;
	for (int i = 0; i < n; i++){
		cin >> v >> u;
		v--;u--;
		
		adj_matrix[v].push_back(u);
		adj_matrix[u].push_back(v);
		
		edges.push_back(make_pair(v, u));
	}
	
	if(k % 2 == 0){
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++)
				dis[j] = 0;
			dis[i] = -1;
			dfs(i, i);
			for (int j = 0; j < n; j++){
				if(dis[i] > (k / 2))
					cnt++;
			}
			ans = min(ans, cnt);
		}
		cout << ans << '\n';
	}else{
		for (int i = 0; i + 1 < n; i++){
			dfs(edges[i].first, edges[i].second);
			
			
		}
	}
	
	return 0;
}