#include <bits/stdc++.h>
using namespace std;
const int maxn = 200500;
const int inf = 1e9 + 7;
int n, k;
vector<int> g[maxn];
long long dp[maxn][5];
long long sz[maxn];
long long cnt = 0;
void dfs(int v, int pr) {
  sz[v] = 1;
  dp[v][0]++;
  for (int to : g[v]) {
    if (to != pr) {
      dfs(to, v);
      sz[v] += sz[to];
      for (int i = 0; i < k; ++i)
        for (int j = 0; j < k; ++j) {
          int d = (i + j + 1) % k;
          if (d > 0) {
            cnt += (k - d) * dp[v][i] * dp[to][j];
          }
        }
      for (int i = 1; i < k; ++i) {
        dp[v][i] += dp[to][i - 1];
      }
      dp[v][0] += dp[to][k - 1];
    }
  }
  cnt += sz[v] * (n - sz[v]);
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(0, 0);
  cout << cnt / k;
  return 0;
}
