#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int nmax = 200010;
vector<int> gr[nmax];
vector<int> parent(nmax, -1e9);
int dp[nmax][6];
int n, k;
int sz[nmax];
long long ans = 0;
int rem(int x, int y) { return (((x - y) % k) + k) % k; }
void dfs(int v, int pr, int mod, int depth) {
  parent[v] = pr;
  dp[v][mod] = 1;
  for (auto &to : gr[v]) {
    if (to == pr) continue;
    dfs(to, v, (mod + 1) % k, depth + 1);
    sz[v] += sz[to];
    for (int i = 1; i <= k; i++) {
      for (int j = 1; j <= k; j++) {
        int ost1 = rem(i + j - 2, 2 * depth);
        int ost2 = rem(k, ost1);
        ans += 1LL * dp[to][j - 1] * ost2 * dp[v][i - 1];
      }
      dp[v][i - 1] += dp[to][i - 1];
    }
  }
}
int32_t main() {
  cin >> n >> k;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    gr[x].push_back(y);
    gr[y].push_back(x);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= 5; j++) dp[i][j] = 0;
    sz[i] = 1;
  }
  dfs(0, -1e9, 0, 0);
  for (int i = 0; i < n; i++) ans += 1LL * sz[i] * (n - sz[i]);
  ans /= k;
  cout << ans;
}
