#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 50;
vector<int> e[N];
long long sz[N][10], dp[N][10];
long long res;
int n, k;
void dfs(int u, int pre) {
  sz[u][0] = 1;
  for (int v : e[u]) {
    if (v == pre) continue;
    dfs(v, u);
    for (int j = 0; j < k; j++)
      for (int l = 0; l < k; l++) {
        long long len = j + l + 1;
        len = ceil(1.0 * len / k);
        res += dp[u][j] * sz[v][l] + dp[v][l] * sz[u][j] +
               len * sz[u][j] * sz[v][l];
      }
    for (int j = 0; j < k; j++) {
      dp[u][(j + 1) % k] += dp[v][j];
      sz[u][(j + 1) % k] += sz[v][j];
      if (j == k - 1) dp[u][(j + 1) % k] += sz[v][j];
    }
  }
}
int main() {
  int u, v;
  res = 0;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &u, &v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  dfs(1, 0);
  printf("%lld\n", res);
}
