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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
typedef tree<
	int, // if multiset, use pair<T, int> as the key where the int is time when added
	null_type,
	less<int>, 
	rb_tree_tag,
	tree_order_statistics_node_update
> ordered_set;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase, insert same as normal set

// DATA TYPES
typedef long long ll;
#define double long double
//

// CONTAINERS
#define vec vector
#define pb push_back
#define ALL(x) begin(x), end(x)
#define SZ(x) (int)x.size()
#define mp make_pair
#define ii pair<int, int>
#define F first
#define S second
template <typename T, typename U>
std::pair<T, U> operator+(const std::pair<T, U> &L, const std::pair<T,U> &R) {
  return {L.first + R.first, L.second + R.second};
}
//

// LOOP
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
//

// BIT
#define bitcount(n) __builtin_popcountll(n)
//

// DEBUG
#define format(x) << #x << ": " << (x)
#define com << ", "
#define ndl << "\n"
#define debug1(x) cerr format(x) ndl;
#define debug2(x, y) cerr format(x) com format(y) ndl;
#define debug3(x, y, z) cerr format(x) com format(y) com format(z) ndl;
#define debug4(x, y, z, w) cerr format(x) com format(y) com format(z) com format(w) ndl;
void debug_out() { cerr << "\n"; }
template <typename H, typename... T>
void debug_out(H h, T... t) { cerr << " " << (h); debug_out(t...); }
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
// 

// CONSTANTS
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = (int)1e9+7; //998244353
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
//

// NUMERICAL OPERATIONS
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

int norm(int a) {
  return ((a % MOD) + MOD) % MOD;
}

int mul(int a, int b) {
  return int(1LL * a * b % MOD);
}

int binPow(int a, int k) {
  int ans = 1;
  for (; k > 0; k >>= 1) {
    if (k & 1) {
      ans = mul(ans, a);
    }
    a = mul(a, a);
  }
  return ans;
}

ll powMod(ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

// If I need to find (x / a) % MOD, I need to use this function:
//    (x / a) % MOD = (x * invMod(a)) % MOD
ll invMod(ll a) {ll b=MOD,u=1,v=0;while(b){ll t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v);} return (MOD + u) % MOD;}

/*
// CAUTION: ONLY WORKS WITH PRIME MOD! Use invMod above instead! 
// If I need to find (x / a) % MOD, I need to use this function:
//    (x / a) % MOD = (x * inv(a)) % MOD
int inv(int a) {
  int b = binPow(a, MOD - 2);
  assert(mul(a, b) == 1);
  return b;
}
*/

int absGcd(int a, int b) {
  return abs(__gcd(a, b));
}
//

// Init variables here
const int N = 2007;
int n, k;
int a[N], b[N];
vector<int> adj[N];

void init() {
  //freopen("??.in", "r", stdin);
  //freopen("??.out", "w", stdout);
  cin >> n >> k;
  FOR(i, 1, n) {
  	cin >> a[i] >> b[i];
  	adj[a[i]].push_back(b[i]);
	adj[b[i]].push_back(a[i]);
  }
}

bool done[N][N];

int dfs(int u, int depth, bool ok[N]) {
	int cur = (depth > k / 2 ? 1 : 0);
	depth++;
	for (int v : adj[u]) {
		if (ok[v]) continue;
		ok[v] = true;
		cur += dfs(v, depth, ok);
	}
	return cur;
}

void solve() {
	int res = n;
	if (k % 2) {
		FOR(i, 1, n) {
			bool *ok = done[i];	
			ok[a[i]] = ok[b[i]] = true;
			res = min(res, dfs(a[i], 0, ok) + dfs(b[i], 0, ok));
		}
	} else {
		FORE(i, 1, n) {
			bool *ok = done[i];
			ok[i] = true;
			res = min(res, dfs(i, 0, ok));
		}
	}
	cout << res << "\n";
  // read the question correctly (is y a vowel?)
  // look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
}

int main() {
  //ios_base::sync_with_stdio(false); cin.tie();
  //int t; scanf("%d", &t); for (int i = 0; i < t; i++) 
  {
    init();
    solve();
  }
  //cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}



Measured memory_bytes: 7788