#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> G[200010];
long long fs[200010][10];
long long dp[200010][10];
long long ans;
void DFS(int u, int fa) {
  dp[u][0] = 1;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == fa) continue;
    DFS(v, u);
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= k; l++) {
        if (!dp[u][j] || !dp[v][l]) continue;
        long long t = j + l + 1;
        if (t % k)
          t = t / k + 1;
        else
          t = t / k;
        ans = ans + t * dp[u][j] * dp[v][l] + dp[u][j] * fs[v][l] +
              fs[u][j] * dp[v][l];
      }
    }
    for (int j = 1; j <= k; j++)
      dp[u][j] += dp[v][j - 1], fs[u][j] += fs[v][j - 1];
    dp[u][1] += dp[v][k];
    fs[u][1] += fs[v][k] + dp[v][k];
  }
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  DFS(1, 0);
  printf("%lld\n", ans);
}
