#include <bits/stdc++.h>
using namespace std;
int n, k, u, v;
long long res = 0, rm = 0;
vector<vector<int> > G(200001, vector<int>());
vector<char> visited(200001, 0);
vector<int> dfs(int u) {
  visited[u] = 1;
  vector<int> du(k, 0);
  du[0] = 1;
  for (int v : G[u]) {
    if (visited[v]) continue;
    vector<int> dv = dfs(v);
    long long sm = accumulate(dv.begin(), dv.end(), 0);
    res += sm * (n - sm);
    for (int i = 0; i < k; i++) {
      for (int j = 0; j < k; j++) {
        if ((i + j + 1) % k)
          res += (k - ((i + j + 1) % k)) * (long long)du[i] * dv[j];
      }
    }
    for (int i = 0; i < k; i++) du[(i + 1) % k] += dv[i];
  }
  return du;
}
void solve() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1);
  cout << res / k << endl;
}
int main() {
  solve();
  return 0;
}
