#include <bits/stdc++.h>
using namespace std;
namespace tree_split2 {
const int N = 310000;
int k;
struct graph {
  int Begin[N * 2], to[N * 2], Next[N * 2], e, weight[N * 2];
  void add(int u, int v) {
    to[++e] = v;
    Next[e] = Begin[u];
    Begin[u] = e;
  }
  void add(int u, int v, int w) {
    to[++e] = v;
    Next[e] = Begin[u];
    Begin[u] = e;
    weight[e] = w;
  }
  void init_graph() {
    e = 0;
    memset(Begin, -1, sizeof(Begin));
  }
};
graph p;
bool vis[N];
int root, size1[N], size2[N], allnode;
void getroot(int now, int fa) {
  size1[now] = 1;
  size2[now] = 0;
  for (int i = p.Begin[now]; i != -1; i = p.Next[i]) {
    int t = p.to[i];
    if (t == fa || vis[t]) continue;
    getroot(t, now);
    size1[now] += size1[t];
    size2[now] = max(size2[now], size1[t]);
  }
  size2[now] = max(allnode - size1[now], size2[now]);
  if (size2[now] < size2[root]) root = now;
}
long long ans;
int deep[2 * N];
int sum[6];
long long sum_0, sz;
void getdeep(int r, int fa) {
  if (r != root) {
    sum_0 += deep[r] / k;
    sum[deep[r] % k]++;
    sz++;
  }
  for (int i = p.Begin[r]; i != -1; i = p.Next[i]) {
    if (p.to[i] != fa && vis[p.to[i]] == false) {
      deep[p.to[i]] = deep[r] + p.weight[i];
      getdeep(p.to[i], r);
    }
  }
}
void calc2(int a, int fa) {
  ans += (deep[a] / k) * (sz + 1);
  int kkk = deep[a] % k;
  if (kkk != 0) ans++;
  ans += sum_0;
  for (int i = 0; i < 5; ++i)
    if (kkk + i > 0 && kkk + i <= k)
      ans += sum[i];
    else if (kkk + i > k)
      ans += sum[i] * 2;
  for (int i = p.Begin[a]; i != -1; i = p.Next[i]) {
    if (p.to[i] != fa && vis[p.to[i]] == false) calc2(p.to[i], a);
  }
}
int sumnode;
void del_(int a, int fa, int now) {
  sumnode++;
  sum_0 -= deep[a] / k;
  sum[deep[a] % k]--;
  sz--;
  for (int i = p.Begin[a]; i != -1; i = p.Next[i]) {
    if (p.to[i] != fa && vis[p.to[i]] == false) del_(p.to[i], a, now);
  }
}
int all_[N * 2];
void calc(int r) {
  getroot(r, r);
  vis[root] = true;
  deep[root] = 0;
  sum_0 = 0;
  sz = 0;
  memset(sum, 0, sizeof(sum));
  getdeep(root, root);
  for (int i = p.Begin[root]; i != -1; i = p.Next[i]) {
    int L = p.to[i];
    if (vis[L] == false) {
      del_(L, root, L);
      calc2(L, root);
      all_[L] = size1[L];
    }
  }
  for (int i = p.Begin[root]; i != -1; i = p.Next[i])
    if (vis[p.to[i]] == false) {
      root = 0;
      allnode = all_[p.to[i]];
      calc(p.to[i]);
    }
}
void init(int n) {
  memset(vis, 0, sizeof(vis));
  memset(size1, 0, sizeof(size1));
  memset(size2, 0, sizeof(size2));
  root = 0;
  p.init_graph();
  allnode = n;
  size2[0] = n + 10;
}
}  // namespace tree_split2
using namespace tree_split2;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, u, v;
  cin >> n >> k;
  p.init_graph();
  init(n);
  ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    cin >> u >> v;
    p.add(u, v, 1), p.add(v, u, 1);
  }
  calc(1);
  cout << ans << endl;
  return 0;
}

### Prompt

Construct a Cpp code solution to the problem outlined:

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;
namespace tree_split2 {
const int N = 310000;
int k;
struct graph {
  int Begin[N * 2], to[N * 2], Next[N * 2], e, weight[N * 2];
  void add(int u, int v) {
    to[++e] = v;
    Next[e] = Begin[u];
    Begin[u] = e;
  }
  void add(int u, int v, int w) {
    to[++e] = v;
    Next[e] = Begin[u];
    Begin[u] = e;
    weight[e] = w;
  }
  void init_graph() {
    e = 0;
    memset(Begin, -1, sizeof(Begin));
  }
};
graph p;
bool vis[N];
int root, size1[N], size2[N], allnode;
void getroot(int now, int fa) {
  size1[now] = 1;
  size2[now] = 0;
  for (int i = p.Begin[now]; i != -1; i = p.Next[i]) {
    int t = p.to[i];
    if (t == fa || vis[t]) continue;
    getroot(t, now);
    size1[now] += size1[t];
    size2[now] = max(size2[now], size1[t]);
  }
  size2[now] = max(allnode - size1[now], size2[now]);
  if (size2[now] < size2[root]) root = now;
}
long long ans;
int deep[2 * N];
int sum[6];
long long sum_0, sz;
void getdeep(int r, int fa) {
  if (r != root) {
    sum_0 += deep[r] / k;
    sum[deep[r] % k]++;
    sz++;
  }
  for (int i = p.Begin[r]; i != -1; i = p.Next[i]) {
    if (p.to[i] != fa && vis[p.to[i]] == false) {
      deep[p.to[i]] = deep[r] + p.weight[i];
      getdeep(p.to[i], r);
    }
  }
}
void calc2(int a, int fa) {
  ans += (deep[a] / k) * (sz + 1);
  int kkk = deep[a] % k;
  if (kkk != 0) ans++;
  ans += sum_0;
  for (int i = 0; i < 5; ++i)
    if (kkk + i > 0 && kkk + i <= k)
      ans += sum[i];
    else if (kkk + i > k)
      ans += sum[i] * 2;
  for (int i = p.Begin[a]; i != -1; i = p.Next[i]) {
    if (p.to[i] != fa && vis[p.to[i]] == false) calc2(p.to[i], a);
  }
}
int sumnode;
void del_(int a, int fa, int now) {
  sumnode++;
  sum_0 -= deep[a] / k;
  sum[deep[a] % k]--;
  sz--;
  for (int i = p.Begin[a]; i != -1; i = p.Next[i]) {
    if (p.to[i] != fa && vis[p.to[i]] == false) del_(p.to[i], a, now);
  }
}
int all_[N * 2];
void calc(int r) {
  getroot(r, r);
  vis[root] = true;
  deep[root] = 0;
  sum_0 = 0;
  sz = 0;
  memset(sum, 0, sizeof(sum));
  getdeep(root, root);
  for (int i = p.Begin[root]; i != -1; i = p.Next[i]) {
    int L = p.to[i];
    if (vis[L] == false) {
      del_(L, root, L);
      calc2(L, root);
      all_[L] = size1[L];
    }
  }
  for (int i = p.Begin[root]; i != -1; i = p.Next[i])
    if (vis[p.to[i]] == false) {
      root = 0;
      allnode = all_[p.to[i]];
      calc(p.to[i]);
    }
}
void init(int n) {
  memset(vis, 0, sizeof(vis));
  memset(size1, 0, sizeof(size1));
  memset(size2, 0, sizeof(size2));
  root = 0;
  p.init_graph();
  allnode = n;
  size2[0] = n + 10;
}
}  // namespace tree_split2
using namespace tree_split2;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, u, v;
  cin >> n >> k;
  p.init_graph();
  init(n);
  ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    cin >> u >> v;
    p.add(u, v, 1), p.add(v, u, 1);
  }
  calc(1);
  cout << ans << endl;
  return 0;
}

```