#include <bits/stdc++.h>
using namespace std;
const int NMax = 2 * 1e5 + 5;
const int inf = 1e9;
long long N, K, sum;
long long nrSub[NMax], path[10], dp[NMax][10];
vector<int> v[NMax];
void dfs(int, int);
int main() {
  cin.tie(0);
  cin.sync_with_stdio(false);
  cin >> N >> K;
  for (int i = 1; i < N; ++i) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, 0);
  long long add = 0;
  for (int i = 1; i < K; ++i) {
    add += (K - i) * path[i];
  }
  cout << (sum + add) / K << '\n';
  return 0;
}
void dfs(int node, int dad) {
  nrSub[node] = 1;
  dp[node][0] = 1;
  for (int s = 0; s < v[node].size(); ++s) {
    int son = v[node][s];
    if (son == dad) {
      continue;
    }
    dfs(son, node);
    nrSub[node] += nrSub[son];
    for (int i = 0; i < K; ++i) {
      for (int j = 0; j < K; ++j) {
        path[(i + j + 1) % K] += dp[node][i] * dp[son][j];
      }
    }
    for (int i = 0; i < K; ++i) {
      dp[node][(i + 1) % K] += dp[son][i];
    }
  }
  sum += nrSub[node] * (N - nrSub[node]);
}
