#include <bits/stdc++.h>
using namespace std;
const double eps = 0.000000000000001;
const int N = 200010;
vector<int> gr[N];
long long way[N][6], sum[N][6];
int n, k;
long long ans = 0;
void dfs(int c, int p) {
  int i, z = gr[c].size(), a, b;
  int x;
  way[c][0] = 1;
  for (i = 0; i < z; i++) {
    if (gr[c][i] == p) continue;
    int v = gr[c][i];
    dfs(v, c);
    for (a = 0; a < k; a++) {
      for (b = 0; b < k; b++) {
        ans += sum[v][b] * way[c][a];
        ans += (way[v][b] * sum[c][a]);
        x = (a + b + 1) / k + ((a + b + 1) == k ? 0 : 1);
        ans += way[c][a] * x * way[v][b];
      }
    }
    for (a = 0; a < k; a++) {
      x = (a == k - 1 ? 0 : a + 1);
      way[c][x] += way[v][a];
      sum[c][x] += sum[v][a] + (a == k - 1 ? 1 : 0) * way[v][a];
    }
  }
}
int main() {
  scanf("%d%d", &n, &k);
  int i, j;
  for (i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    gr[x].push_back(y);
    gr[y].push_back(x);
  }
  dfs(1, 0);
  printf("%lld\n", ans);
  return 0;
}
