#include <bits/stdc++.h>
using namespace std;
vector<int> e[1000001];
bool vis[1000001];
int a[1000001], n, k, x, y;
long long ans = 1;
inline int read() {
int ret = 0;
char ch = getchar();
while (ch < '0' || ch > '9')
ch = getchar();
while (ch >= '0' && ch <= '9')
ret = (ret << 3) + (ret << 1) + ch - '0', ch = getchar();
return ret;
}
void dfs(int i) {
if (a[i] != k || vis[i])
return;
ans += k - 1;
vis[i] = true;
for (int ed : e[i])
a[ed]--;
for (int ed : e[i])
dfs(ed);
}
int main() {
n = read(), k = read();
for (int i = 1; i < n; i++) {
x = read(), y = read();
e[x].push_back(y);
e[y].push_back(x);
a[x]++, a[y]++;
}
for (int i = 1; i <= n; i++)
dfs(i);
printf("%lld", ans);
return 0;
}