#define _GLIBCXX_FILESYSTEM
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
int n,k;
const int N = 2e5+5;
vector<int> g[N];
int mx;
void dfs(int u,int p = 0,int d = 1) {
mx = max(mx, d);
for(auto x: g[u]) {
if(x == p) continue;
dfs(x,u,d+1);
}
return;
}
void solve() {
cin >> n >> k;
for(int i = 1; i < n; i++) {
int u,v;
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
dfs(1);
cout << min(n, k + mx) << '\n';
return;
}
int32_t main() {
ios_base::sync_with_stdio(false);cin.tie(NULL);
int tc = 1;
// cin >> tc;
for(int kase = 1; kase <= tc; kase++) {
//cout << "Case " << kase << ": ";
solve();
}
return 0;
}