#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int M = 2e5 + 5, N = 6;
int n, k;
vector<int> g[M];
long long d[M][N];
long long ans[N], dv[M], an, anl[M][N];
void dfs(int v, int pr = -1) {
  d[v][0] = 1;
  dv[v] = 1;
  for (int i = 0; i < g[v].size(); ++i)
    if (g[v][i] != pr) dfs(g[v][i], v), dv[v] += dv[g[v][i]];
  for (int j = 0; j < k; ++j)
    for (int i = 0; i < g[v].size(); ++i)
      if (g[v][i] != pr)
        d[v][(j + 1) % k] += d[g[v][i]][j], ans[(j + 1) % k] += d[g[v][i]][j];
  for (int j = 0; j < k; ++j)
    for (int h = 0; h < k; ++h)
      for (int i = 0; i < g[v].size(); ++i)
        if (g[v][i] != pr) {
          int x = d[g[v][i]][(h - 1 + k) % k];
          if (h == 0) x += 1;
          anl[v][(j + 1 + h) % k] += d[g[v][i]][j] * (d[v][h] - x);
        }
  for (int i = 0; i < k; ++i) ans[i] += anl[v][i] / 2;
  an += dv[v] * (n - dv[v]);
}
int main() {
  cin >> n >> k;
  int v, u;
  for (int i = 0; i < n - 1; ++i) {
    cin >> v >> u;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  dfs(1);
  for (int j = 1; j < k; ++j) an += ans[j] * ((-j + k) % k);
  cout << an / k;
}
