#include <bits/stdc++.h>
using namespace std;
const long long N = 2 * 1e5 + 9;
const long long oo = 1e15;
const long long mod = 1e9 + 7;
long long n, k, sum;
long long dp[N][6], child[N];
vector<long long> vi[N];
void dfs(long long pre, long long u) {
  child[u] = 1;
  dp[u][0] = 1;
  for (long long v : vi[u]) {
    if (v != pre) {
      dfs(u, v);
      child[u] += child[v];
      sum += child[v] * (n - child[v]);
      for (long long j = 0; j <= k - 1; ++j)
        for (long long t = 0; t <= k - 1; ++t)
          if ((j + 1 + t) % k != 0)
            sum += dp[u][j] * dp[v][t] * (k - (j + t + 1) % k);
      for (long long j = 0; j < k; ++j) dp[u][(j + 1) % k] += dp[v][j];
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (long long i = 1; i < n; ++i) {
    long long x, y;
    cin >> x >> y;
    vi[x].push_back(y);
    vi[y].push_back(x);
  }
  dfs(1, 1);
  cout << sum / k;
}
