'use strict';

Array.prototype._sort = Array.prototype.sort;
Array.prototype.sort = function (fn) {
	if (fn) {
		return this._sort(fn);
		
	} else if (typeof this[0] === 'number') {
		return this._sort((a, b) => a - b);
		
	} else {
		return this._sort();
	}
};

function gcd(a, b) {
	while (true) {
		if (a > b) {
			a = a % b;
			if (a === 0) return b;
		} else {
			b = b % a;
			if (b === 0) return a;
		}
	}
}

function tree(pairs) {
	let tree = new Map();
	for (let ab of pairs) {
		let a = ab[0], b = ab[1];
		
		if (!tree.has(a)) tree.set(a, new Set());
		if (!tree.has(b)) tree.set(b, new Set());
		
		let nodeA = tree.get(a),
			nodeB = tree.get(b);
		
		nodeA.add(b);
		nodeB.add(a);
	}
	
	return tree;
}

const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');

const NK = lines[0].split(' ').map(Number);
const N = NK[0];
const K = NK[1];
const AB = lines.slice(1).map(l => l.split(' ').map(Number));

let t = tree(AB);

let result = N;
const r = Math.floor(K / 2);

for (let c = 1; c <= N; c++) {
	let flag = new Set(),
		que = [c],
		d = 0;
	
	flag.add(c);
	
	while (que.length > 0) {
		let nextQue = [];
		d++;
		
		let nexts = t.get(que.shift());
		
		for (let next of nexts) {
			if (flag.has(next)) continue;
			
			nextQue.push(next);
			flag.add(next);
		}
		
		que = nextQue;
		
		if (d === r) {
			if ((K & 1) === 0) {
				result = Math.min(result, N - flag.size);
			} else {
				result = Math.min(result, N - flag.size - 1);
			}
			break;
		}
	}
}

console.log(result);