#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const int K = 10;
int n, k;
vector<int> e[N];
long long d[N], siz[N], sum[N], num[N][K], f[N][K];
void dfs1(int u, int fa) {
  siz[u] = 1;
  for (auto v : e[u]) {
    if (v != fa) {
      dfs1(v, u);
      siz[u] += siz[v];
    }
  }
}
void dfs2(int u, int fa) {
  d[u] = 0;
  for (auto v : e[u]) {
    if (v != fa) {
      dfs2(v, u);
      sum[u] += (d[v] + siz[v]) * (siz[u] - siz[v]);
      d[u] += d[v] + siz[v];
    }
  }
}
void dfs3(int u, int fa) {
  for (int o = 0; o < k; ++o) num[u][o] = 0;
  num[u][0] = 1;
  for (auto v : e[u]) {
    if (v != fa) {
      dfs3(v, u);
      for (int ou = 0; ou < k; ++ou) {
        for (int ov = 0; ov < k; ++ov) {
          int nw = (ou + ov + 1) % k;
          if (nw != 0) nw = k - nw;
          f[u][nw] += num[u][ou] * num[v][ov];
        }
      }
      for (int ov = 0; ov < k; ++ov) {
        num[u][(ov + 1) % k] += num[v][ov];
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  dfs1(1, 0);
  dfs2(1, 0);
  dfs3(1, 0);
  long long s = 0;
  for (int i = 1; i <= n; ++i) {
    s += sum[i];
  }
  for (int i = 1; i <= n; ++i) {
    for (int o = 0; o < k; ++o) {
      s += f[i][o] * o;
    }
  }
  cout << s / k << "\n";
  return 0;
}
