#include <bits/stdc++.h>
using namespace std;
struct vec {
  vector<long long> v;
  vector<long long> n;
  int k;
  vec(int kk) {
    k = kk;
    v = vector<long long>(k);
    n = vector<long long>(k);
  }
  void operator+=(vec &u) {
    for (int i = (0); i < (k); ++i) {
      v[i] += u.v[i];
      n[i] += u.n[i];
    }
  }
  void inc() {
    long long x = v[k - 1], y = n[k - 1] + 1;
    for (int i = (k - 1); i >= (1); --i) {
      v[i] = v[i - 1];
      n[i] = n[i - 1];
    }
    v[0] = x + y;
    n[0] = y;
  }
  long long sum() {
    long long s = 0;
    for (int i = (0); i < (k); ++i) s += v[i];
    return s;
  }
  long long nsum() {
    long long s = 0;
    for (int i = (0); i < (k); ++i) s += n[i];
    return s;
  }
};
long long add(vec &a, vec &b, int k) {
  long long as = a.sum(), bs = b.sum(), an = a.nsum(), bn = b.nsum();
  long long ret = as * bn + an * bs;
  for (int i = (0); i < (k - 1); ++i) {
    bn -= b.n[k - 1 - i];
    ret -= a.n[i] * bn;
  }
  return ret;
}
void solve(vector<vector<long long> > &tree, vector<vec> &dist,
           vector<long long> &vis, long long &ans, long long st, int k) {
  if (vis[st]) return;
  vis[st] = 1;
  for (int i = (0); i < (tree[st].size()); ++i) {
    int cur = tree[st][i];
    if (vis[cur]) continue;
    solve(tree, dist, vis, ans, cur, k);
    dist[cur].inc();
    ans += add(dist[st], dist[cur], k);
    dist[st] += dist[cur];
  }
  ans += dist[st].sum();
}
int main() {
  ios_base::sync_with_stdio(false);
  long long n;
  int k;
  cin >> n >> k;
  vector<vector<long long> > tree(n);
  for (int i = (0); i < (n - 1); ++i) {
    long long x, y;
    cin >> x >> y;
    --x;
    --y;
    tree[x].push_back(y);
    tree[y].push_back(x);
  }
  long long ans = 0;
  vector<long long> vis(n);
  vec v(k);
  vector<vec> dist(n, v);
  solve(tree, dist, vis, ans, 0, k);
  cout << ans << "\n";
  return 0;
}

### Prompt

Create a solution in CPP for 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;
struct vec {
  vector<long long> v;
  vector<long long> n;
  int k;
  vec(int kk) {
    k = kk;
    v = vector<long long>(k);
    n = vector<long long>(k);
  }
  void operator+=(vec &u) {
    for (int i = (0); i < (k); ++i) {
      v[i] += u.v[i];
      n[i] += u.n[i];
    }
  }
  void inc() {
    long long x = v[k - 1], y = n[k - 1] + 1;
    for (int i = (k - 1); i >= (1); --i) {
      v[i] = v[i - 1];
      n[i] = n[i - 1];
    }
    v[0] = x + y;
    n[0] = y;
  }
  long long sum() {
    long long s = 0;
    for (int i = (0); i < (k); ++i) s += v[i];
    return s;
  }
  long long nsum() {
    long long s = 0;
    for (int i = (0); i < (k); ++i) s += n[i];
    return s;
  }
};
long long add(vec &a, vec &b, int k) {
  long long as = a.sum(), bs = b.sum(), an = a.nsum(), bn = b.nsum();
  long long ret = as * bn + an * bs;
  for (int i = (0); i < (k - 1); ++i) {
    bn -= b.n[k - 1 - i];
    ret -= a.n[i] * bn;
  }
  return ret;
}
void solve(vector<vector<long long> > &tree, vector<vec> &dist,
           vector<long long> &vis, long long &ans, long long st, int k) {
  if (vis[st]) return;
  vis[st] = 1;
  for (int i = (0); i < (tree[st].size()); ++i) {
    int cur = tree[st][i];
    if (vis[cur]) continue;
    solve(tree, dist, vis, ans, cur, k);
    dist[cur].inc();
    ans += add(dist[st], dist[cur], k);
    dist[st] += dist[cur];
  }
  ans += dist[st].sum();
}
int main() {
  ios_base::sync_with_stdio(false);
  long long n;
  int k;
  cin >> n >> k;
  vector<vector<long long> > tree(n);
  for (int i = (0); i < (n - 1); ++i) {
    long long x, y;
    cin >> x >> y;
    --x;
    --y;
    tree[x].push_back(y);
    tree[y].push_back(x);
  }
  long long ans = 0;
  vector<long long> vis(n);
  vec v(k);
  vector<vec> dist(n, v);
  solve(tree, dist, vis, ans, 0, k);
  cout << ans << "\n";
  return 0;
}

```