#include <bits/stdc++.h>
using namespace std;
const long long maxinput = 200005;
const long long mod = 1000000007;
long long n, k;
vector<long long> adj[maxinput];
long long in[maxinput][5];
long long out[maxinput][5];
long long subtree[maxinput];
long long sum = 0;
void dfs1(long long u, long long par) {
  long long v;
  for (long long i = 0; i < k; i++) in[u][i] = 0;
  in[u][0] = 1;
  subtree[u] = 1;
  for (long long j = 0; j < adj[u].size(); j++) {
    v = adj[u][j];
    if (v != par) {
      dfs1(v, u);
      subtree[u] += subtree[v];
      for (long long i = 0; i < k; i++) in[u][(i + 1) % k] += in[v][i];
    }
  }
  sum += subtree[u] * (n - subtree[u]);
}
void dfs2(long long u, long long par) {
  long long v;
  for (long long i = 0; i < k; i++) out[u][i] = 0;
  if (u != 1) {
    for (long long i = 0; i < k; i++)
      out[u][(i + 1) % k] += out[par][i] + in[par][i] - in[u][(i - 1 + k) % k];
  }
  for (long long i = 0; i < adj[u].size(); i++) {
    v = adj[u][i];
    if (v != par) dfs2(v, u);
  }
}
int main() {
  cin >> n >> k;
  for (long long i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs1(1, 0);
  dfs2(1, 0);
  long long residue = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j < k; j++) {
      residue += ((k - j) % k) * (in[i][j] + out[i][j]);
    }
  }
  cout << (sum + (residue) / 2) / k;
}
