#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
struct Edge {
  int u, v, next;
} e[MAXN * 2];
int head[MAXN], tot;
void init() {
  memset(head, -1, sizeof(head));
  tot = 0;
}
void add_edge(int u, int v) {
  e[tot].u = u, e[tot].v = v, e[tot].next = head[u];
  head[u] = tot++;
}
int n, k;
long long int dp[MAXN][6], size[MAXN];
long long int ans = 0, tmp = 0;
void dfs(int u, int fa) {
  size[u] = 1;
  for (int i = head[u]; i != -1; i = e[i].next) {
    int v = e[i].v;
    if (v == fa) continue;
    dfs(v, u);
    ans += size[v] * (n - size[v]);
    size[u] += size[v];
    for (int j = 0; j < k; j++) {
      for (int l = 0; l < k; l++) {
        long long int ta = dp[u][j];
        long long int tb = dp[v][l];
        if (l == 0) tb++;
        tmp += ((k - (j + l + 1) % k) % k) * ta * tb;
      }
    }
    for (int j = 0; j < k; j++) dp[u][j] += dp[v][(j - 1 + k) % k];
    dp[u][1]++;
  }
  for (int i = 1; i < k; i++) tmp += (k - i) * dp[u][i];
  return;
}
int main() {
  scanf("%d%d", &n, &k);
  init();
  int u, v;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    add_edge(u, v);
    add_edge(v, u);
  }
  memset(size, 0, sizeof(size));
  dfs(1, 1);
  if (k == 1) {
    printf("%I64d\n", ans);
    return 0;
  }
  printf("%I64d\n", (ans + tmp) / k);
  return 0;
}
