#include <bits/stdc++.h>
using namespace ::std;
const long long maxn = 2e5 + 500;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 500;
long long dp[maxn][6];
long long dpp[maxn][6];
long long ans = 0;
vector<long long> ger[maxn];
bool vis[maxn];
long long k;
void dfs(long long a) {
  vis[a] = 1;
  long long par = -1;
  for (long long i = 0; i < ger[a].size(); i++) {
    long long v = ger[a][i];
    if (vis[v] == 0) {
      dfs(v);
    } else {
      par = v;
    }
  }
  for (long long i = 0; i < ger[a].size(); i++) {
    long long v = ger[a][i];
    if (v != par) {
      for (long long j = 1; j <= k; j++) {
        for (long long t = 1; t <= k; t++) {
          if (t + j + 1 <= k) {
            ans += dpp[a][t] * dp[v][j];
            ans += dp[a][t] * dpp[v][j];
            ans -= dpp[a][t] * dpp[v][j];
          } else if (j != k || t != k) {
            ans += dpp[a][t] * dp[v][j];
            ans += dp[a][t] * dpp[v][j];
          } else {
            ans += dpp[a][t] * dp[v][j];
            ans += dp[a][t] * dpp[v][j];
            ans += dpp[a][t] * dpp[v][j];
          }
        }
      }
      for (long long j = 1; j <= k; j++) {
        ans += dp[v][j];
      }
      ans += dpp[v][k];
      for (long long j = 2; j <= k; j++) {
        dp[a][j] += dp[v][j - 1];
        dpp[a][j] += dpp[v][j - 1];
      }
      dpp[a][1] += dpp[v][k];
      dp[a][1] += dp[v][k] + dpp[v][k];
    }
  }
  dpp[a][k]++;
}
int main() {
  long long n;
  cin >> n >> k;
  for (long long i = 1; i < n; i++) {
    long long v, u;
    cin >> v >> u;
    u--;
    v--;
    ger[u].push_back(v);
    ger[v].push_back(u);
  }
  dfs(0);
  cout << ans;
}

### Prompt

Please formulate a CPP solution to the following problem:

A tree is an undirected connected graph without cycles. The distance between two vertices is the number of edges in a simple path between them.

Limak is a little polar bear. He lives in a tree that consists of n vertices, numbered 1 through n.

Limak recently learned how to jump. He can jump from a vertex to any vertex within distance at most k.

For a pair of vertices (s, t) we define f(s, t) as the minimum number of jumps Limak needs to get from s to t. Your task is to find the sum of f(s, t) over all pairs of vertices (s, t) such that s < t.

Input

The first line of the input contains two integers n and k (2 ≤ n ≤ 200 000, 1 ≤ k ≤ 5) — the number of vertices in the tree and the maximum allowed jump distance respectively.

The next n - 1 lines describe edges in the tree. The i-th of those lines contains two integers ai and bi (1 ≤ ai, bi ≤ n) — the indices on vertices connected with i-th edge.

It's guaranteed that the given edges form a tree.

Output

Print one integer, denoting the sum of f(s, t) over all pairs of vertices (s, t) such that s < t.

Examples

Input

6 2
1 2
1 3
2 4
2 5
4 6


Output

20


Input

13 3
1 2
3 2
4 2
5 2
3 6
10 6
6 7
6 13
5 8
5 9
9 11
11 12


Output

114


Input

3 5
2 1
3 1


Output

3

Note

In the first sample, the given tree has 6 vertices and it's displayed on the drawing below. Limak can jump to any vertex within distance at most 2. For example, from the vertex 5 he can jump to any of vertices: 1, 2 and 4 (well, he can also jump to the vertex 5 itself).

<image>

There are <image> pairs of vertices (s, t) such that s < t. For 5 of those pairs Limak would need two jumps: (1, 6), (3, 4), (3, 5), (3, 6), (5, 6). For other 10 pairs one jump is enough. So, the answer is 5·2 + 10·1 = 20.

In the third sample, Limak can jump between every two vertices directly. There are 3 pairs of vertices (s < t), so the answer is 3·1 = 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace ::std;
const long long maxn = 2e5 + 500;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 500;
long long dp[maxn][6];
long long dpp[maxn][6];
long long ans = 0;
vector<long long> ger[maxn];
bool vis[maxn];
long long k;
void dfs(long long a) {
  vis[a] = 1;
  long long par = -1;
  for (long long i = 0; i < ger[a].size(); i++) {
    long long v = ger[a][i];
    if (vis[v] == 0) {
      dfs(v);
    } else {
      par = v;
    }
  }
  for (long long i = 0; i < ger[a].size(); i++) {
    long long v = ger[a][i];
    if (v != par) {
      for (long long j = 1; j <= k; j++) {
        for (long long t = 1; t <= k; t++) {
          if (t + j + 1 <= k) {
            ans += dpp[a][t] * dp[v][j];
            ans += dp[a][t] * dpp[v][j];
            ans -= dpp[a][t] * dpp[v][j];
          } else if (j != k || t != k) {
            ans += dpp[a][t] * dp[v][j];
            ans += dp[a][t] * dpp[v][j];
          } else {
            ans += dpp[a][t] * dp[v][j];
            ans += dp[a][t] * dpp[v][j];
            ans += dpp[a][t] * dpp[v][j];
          }
        }
      }
      for (long long j = 1; j <= k; j++) {
        ans += dp[v][j];
      }
      ans += dpp[v][k];
      for (long long j = 2; j <= k; j++) {
        dp[a][j] += dp[v][j - 1];
        dpp[a][j] += dpp[v][j - 1];
      }
      dpp[a][1] += dpp[v][k];
      dp[a][1] += dp[v][k] + dpp[v][k];
    }
  }
  dpp[a][k]++;
}
int main() {
  long long n;
  cin >> n >> k;
  for (long long i = 1; i < n; i++) {
    long long v, u;
    cin >> v >> u;
    u--;
    v--;
    ger[u].push_back(v);
    ger[v].push_back(u);
  }
  dfs(0);
  cout << ans;
}

```