#include <bits/stdc++.h>
using namespace std;
const int maxN = 200005;
long long n, k;
long long V2[6];
int vis[maxN];
vector<int> G[maxN];
long long ans;
long long dfs(int s) {
  vis[s] = 1;
  int V1[5] = {1, 0, 0, 0, 0};
  long long cnt = 1;
  for (auto it : G[s]) {
    if (!vis[it]) {
      long long tmp = dfs(it);
      cnt += tmp;
      ans += tmp * (n - tmp);
      for (int i = 0; i < k; ++i)
        for (int j = 0; j < k; ++j) {
          long long md = (i + j) % k;
          ans += ((k - md) % k) * V1[i] * V2[j];
        }
      for (int i = 0; i < k; ++i) V1[i] += V2[i];
    }
  }
  for (int i = 0; i < k; ++i) V2[(i + 1) % k] = V1[i];
  return cnt;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(1);
  cout << ans / k << endl;
  return 0;
}
