#include <bits/stdc++.h>
template <typename Arg1>
void ZZ(const char* name, Arg1&& arg1) {
  std::cout << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cout.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
using namespace std;
long long int to_ll(string& s) {
  long long int i, ret = 0, p = 1;
  for (i = (long long int)s.length() - 1; i >= 0; i--)
    ret += (s[i] - '0') * p, p *= 10LL;
  return ret;
}
long long int gcd(long long int x, long long int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long int pwr(long long int base, long long int expo, long long int m) {
  if (base == 0) return 0LL;
  if (expo == 0) return (1LL % m);
  if ((expo & 1) == 0) {
    long long int temp = pwr(base, expo >> 1, m);
    return (temp * temp) % m;
  }
  return ((base % m) * pwr(base, expo - 1, m)) % 1000000007;
}
vector<long long int> adj[200009];
long long int dp_down[200009][5], dp_up[200009][5], sz_down[200009][5],
    sz_up[200009][5], p[200009], dp[200009][5], dp_sz[200009][5];
bool v_dp_down[200009][5], v_dp_up[200009][5], v_sz_down[200009][5],
    v_sz_up[200009][5];
long long int n, k;
void dfs(long long int node, long long int parent) {
  long long int i;
  p[node] = parent;
  for (i = 0; i < adj[node].size(); i++) {
    long long int nxt = adj[node][i];
    if (nxt == parent) continue;
    dfs(nxt, node);
  }
}
void dfs_sz_down(long long int node, long long int parent, long long int m) {
  long long int i;
  if (v_sz_down[node][m] == 1) return;
  v_sz_down[node][m] = 1;
  for (i = 0; i < adj[node].size(); i++) {
    long long int nxt = adj[node][i];
    long long int nxt_m = ((m - 1) % k + k) % k;
    if (nxt == parent) continue;
    dfs_sz_down(nxt, node, nxt_m);
    sz_down[node][m] += sz_down[nxt][nxt_m];
    dp_sz[node][nxt_m] += sz_down[nxt][nxt_m];
  }
  if (m == 0) sz_down[node][m]++;
}
void dfs_sz_up(long long int node, long long int parent, long long int m) {
  if (v_sz_up[node][m] == 1) return;
  v_sz_up[node][m] = 1;
  if (m == 0) sz_up[node][m]++;
  if (parent == -1) return;
  long long int nxt_m = ((m - 1) % k + k) % k, i;
  dfs_sz_up(parent, p[parent], nxt_m);
  sz_up[node][m] += sz_up[parent][nxt_m];
  sz_up[node][m] += dp_sz[parent][((m - 2) % k + k) % k];
  sz_up[node][m] -= sz_down[node][((m - 2) % k + k) % k];
}
void dfs_up(long long int node, long long int parent, long long int m) {
  if (v_dp_up[node][m] == 1) return;
  v_dp_up[node][m] = 1;
  if (parent == -1) return;
  long long int nxt_m = ((m - 1) % k + k) % k, i;
  dfs_up(parent, p[parent], nxt_m);
  dp_up[node][m] += sz_up[parent][nxt_m] + dp_up[parent][nxt_m];
  dp_up[node][m] += dp[parent][((m - 2) % k + k) % k];
  dp_up[node][m] -= (2 * sz_down[node][((m - 2) % k + k) % k] +
                     dp_down[node][((m - 2) % k + k) % k]);
}
void dfs_down(long long int node, long long int parent, long long int m) {
  if (v_dp_down[node][m] == 1) return;
  v_dp_down[node][m] = 1;
  long long int i;
  for (i = 0; i < adj[node].size(); i++) {
    long long int nxt = adj[node][i];
    long long int nxt_m = ((m - 1) % k + k) % k;
    if (nxt == parent) continue;
    dfs_down(nxt, node, nxt_m);
    dp_down[node][m] += sz_down[nxt][nxt_m] + dp_down[nxt][nxt_m];
    dp[node][nxt_m] += (2 * sz_down[nxt][nxt_m] + dp_down[nxt][nxt_m]);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int i, j, x, y, ans = 0;
  cin >> n >> k;
  for (i = 0; i < n - 1; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1, -1);
  for (i = 1; i <= n; i++)
    for (j = 0; j < k; j++) dfs_sz_down(i, p[i], j);
  for (i = 1; i <= n; i++)
    for (j = 0; j < k; j++) dfs_sz_up(i, p[i], j);
  for (i = 1; i <= n; i++)
    for (j = 0; j < k; j++) dfs_down(i, p[i], j);
  for (i = 1; i <= n; i++)
    for (j = 0; j < k; j++) dfs_up(i, p[i], j);
  for (j = 0; j < k; j++) {
    for (i = 1; i <= n; i++) {
      long long int total = dp_up[i][j] + dp_down[i][j];
      long long int total_sz = sz_down[i][j] + sz_up[i][j];
      if (j == 0) total_sz--;
      long long int val = ((total - total_sz * j) / k);
      if (j != 0) val += total_sz;
      ans += val;
    }
  }
  cout << ans / 2 << "\n";
  return 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

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>
template <typename Arg1>
void ZZ(const char* name, Arg1&& arg1) {
  std::cout << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cout.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
using namespace std;
long long int to_ll(string& s) {
  long long int i, ret = 0, p = 1;
  for (i = (long long int)s.length() - 1; i >= 0; i--)
    ret += (s[i] - '0') * p, p *= 10LL;
  return ret;
}
long long int gcd(long long int x, long long int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long int pwr(long long int base, long long int expo, long long int m) {
  if (base == 0) return 0LL;
  if (expo == 0) return (1LL % m);
  if ((expo & 1) == 0) {
    long long int temp = pwr(base, expo >> 1, m);
    return (temp * temp) % m;
  }
  return ((base % m) * pwr(base, expo - 1, m)) % 1000000007;
}
vector<long long int> adj[200009];
long long int dp_down[200009][5], dp_up[200009][5], sz_down[200009][5],
    sz_up[200009][5], p[200009], dp[200009][5], dp_sz[200009][5];
bool v_dp_down[200009][5], v_dp_up[200009][5], v_sz_down[200009][5],
    v_sz_up[200009][5];
long long int n, k;
void dfs(long long int node, long long int parent) {
  long long int i;
  p[node] = parent;
  for (i = 0; i < adj[node].size(); i++) {
    long long int nxt = adj[node][i];
    if (nxt == parent) continue;
    dfs(nxt, node);
  }
}
void dfs_sz_down(long long int node, long long int parent, long long int m) {
  long long int i;
  if (v_sz_down[node][m] == 1) return;
  v_sz_down[node][m] = 1;
  for (i = 0; i < adj[node].size(); i++) {
    long long int nxt = adj[node][i];
    long long int nxt_m = ((m - 1) % k + k) % k;
    if (nxt == parent) continue;
    dfs_sz_down(nxt, node, nxt_m);
    sz_down[node][m] += sz_down[nxt][nxt_m];
    dp_sz[node][nxt_m] += sz_down[nxt][nxt_m];
  }
  if (m == 0) sz_down[node][m]++;
}
void dfs_sz_up(long long int node, long long int parent, long long int m) {
  if (v_sz_up[node][m] == 1) return;
  v_sz_up[node][m] = 1;
  if (m == 0) sz_up[node][m]++;
  if (parent == -1) return;
  long long int nxt_m = ((m - 1) % k + k) % k, i;
  dfs_sz_up(parent, p[parent], nxt_m);
  sz_up[node][m] += sz_up[parent][nxt_m];
  sz_up[node][m] += dp_sz[parent][((m - 2) % k + k) % k];
  sz_up[node][m] -= sz_down[node][((m - 2) % k + k) % k];
}
void dfs_up(long long int node, long long int parent, long long int m) {
  if (v_dp_up[node][m] == 1) return;
  v_dp_up[node][m] = 1;
  if (parent == -1) return;
  long long int nxt_m = ((m - 1) % k + k) % k, i;
  dfs_up(parent, p[parent], nxt_m);
  dp_up[node][m] += sz_up[parent][nxt_m] + dp_up[parent][nxt_m];
  dp_up[node][m] += dp[parent][((m - 2) % k + k) % k];
  dp_up[node][m] -= (2 * sz_down[node][((m - 2) % k + k) % k] +
                     dp_down[node][((m - 2) % k + k) % k]);
}
void dfs_down(long long int node, long long int parent, long long int m) {
  if (v_dp_down[node][m] == 1) return;
  v_dp_down[node][m] = 1;
  long long int i;
  for (i = 0; i < adj[node].size(); i++) {
    long long int nxt = adj[node][i];
    long long int nxt_m = ((m - 1) % k + k) % k;
    if (nxt == parent) continue;
    dfs_down(nxt, node, nxt_m);
    dp_down[node][m] += sz_down[nxt][nxt_m] + dp_down[nxt][nxt_m];
    dp[node][nxt_m] += (2 * sz_down[nxt][nxt_m] + dp_down[nxt][nxt_m]);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int i, j, x, y, ans = 0;
  cin >> n >> k;
  for (i = 0; i < n - 1; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1, -1);
  for (i = 1; i <= n; i++)
    for (j = 0; j < k; j++) dfs_sz_down(i, p[i], j);
  for (i = 1; i <= n; i++)
    for (j = 0; j < k; j++) dfs_sz_up(i, p[i], j);
  for (i = 1; i <= n; i++)
    for (j = 0; j < k; j++) dfs_down(i, p[i], j);
  for (i = 1; i <= n; i++)
    for (j = 0; j < k; j++) dfs_up(i, p[i], j);
  for (j = 0; j < k; j++) {
    for (i = 1; i <= n; i++) {
      long long int total = dp_up[i][j] + dp_down[i][j];
      long long int total_sz = sz_down[i][j] + sz_up[i][j];
      if (j == 0) total_sz--;
      long long int val = ((total - total_sz * j) / k);
      if (j != 0) val += total_sz;
      ans += val;
    }
  }
  cout << ans / 2 << "\n";
  return 0;
}

```