#include <bits/stdc++.h>
using namespace std;
long n, k;
long long all_path = 0;
long long rem[5] = {};
vector<long> g[200000];
long long dp[200000][5] = {};
bool vis[200000] = {};
bool done[200000] = {};
void dfs(long now) {
  vis[now] = 1;
  dp[now][0] = 1;
  for (long long f = (long long)0; f <= (long long)g[now].size() - 1; ++f) {
    if (!vis[g[now][f]]) {
      dfs(g[now][f]);
    }
  }
  long long tmp[5] = {};
  bool first = 1;
  for (long long f = (long long)0; f <= (long long)g[now].size() - 1; ++f) {
    if (done[g[now][f]]) {
      if (first) {
        for (long long ff = (long long)0; ff <= (long long)k - 1; ++ff) {
          tmp[ff] = dp[g[now][f]][ff];
        }
        first = 0;
      } else {
        for (long long ff = (long long)0; ff <= (long long)k - 1; ++ff) {
          for (long long fff = (long long)0; fff <= (long long)k - 1; ++fff) {
            rem[(ff + fff + 2) % k] += tmp[ff] * dp[g[now][f]][fff];
          }
          tmp[ff] += dp[g[now][f]][ff];
        }
      }
    }
  }
  for (long long f = (long long)0; f <= (long long)k - 1; ++f) {
    dp[now][(f + 1) % k] += tmp[f];
  }
  for (long long f = (long long)0; f <= (long long)k - 1; ++f) {
    rem[f] += dp[now][f];
  }
  done[now] = 1;
}
bool vis1[200000] = {};
bool done1[200000] = {};
long long dp1[200000] = {};
void calc_all_path1(long now) {
  vis1[now] = 1;
  dp1[now] = 1;
  for (long long f = (long long)0; f <= (long long)g[now].size() - 1; ++f) {
    if (!vis1[g[now][f]]) {
      calc_all_path1(g[now][f]);
    }
  }
  for (long long f = (long long)0; f <= (long long)g[now].size() - 1; ++f) {
    if (done1[g[now][f]]) {
      dp1[now] += dp1[g[now][f]];
    }
  }
  done1[now] = 1;
}
bool vis2[200000] = {};
void calc_all_path2(long now) {
  vis2[now] = 1;
  for (long long f = (long long)0; f <= (long long)g[now].size() - 1; ++f) {
    if (!vis2[g[now][f]]) {
      all_path += (dp1[0] - dp1[g[now][f]]) * dp1[g[now][f]];
      calc_all_path2(g[now][f]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(15);
  cin >> n >> k;
  for (long long f = (long long)0; f <= (long long)n - 2; ++f) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(0);
  rem[0] -= n;
  calc_all_path1(0);
  calc_all_path2(0);
  long long x = 0;
  for (long long f = (long long)1; f <= (long long)k - 1; ++f) {
    x += rem[f] * (k - f);
  }
  cout << (all_path + x) / k;
  return 0;
}

### Prompt

Develop a solution in Cpp 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>
using namespace std;
long n, k;
long long all_path = 0;
long long rem[5] = {};
vector<long> g[200000];
long long dp[200000][5] = {};
bool vis[200000] = {};
bool done[200000] = {};
void dfs(long now) {
  vis[now] = 1;
  dp[now][0] = 1;
  for (long long f = (long long)0; f <= (long long)g[now].size() - 1; ++f) {
    if (!vis[g[now][f]]) {
      dfs(g[now][f]);
    }
  }
  long long tmp[5] = {};
  bool first = 1;
  for (long long f = (long long)0; f <= (long long)g[now].size() - 1; ++f) {
    if (done[g[now][f]]) {
      if (first) {
        for (long long ff = (long long)0; ff <= (long long)k - 1; ++ff) {
          tmp[ff] = dp[g[now][f]][ff];
        }
        first = 0;
      } else {
        for (long long ff = (long long)0; ff <= (long long)k - 1; ++ff) {
          for (long long fff = (long long)0; fff <= (long long)k - 1; ++fff) {
            rem[(ff + fff + 2) % k] += tmp[ff] * dp[g[now][f]][fff];
          }
          tmp[ff] += dp[g[now][f]][ff];
        }
      }
    }
  }
  for (long long f = (long long)0; f <= (long long)k - 1; ++f) {
    dp[now][(f + 1) % k] += tmp[f];
  }
  for (long long f = (long long)0; f <= (long long)k - 1; ++f) {
    rem[f] += dp[now][f];
  }
  done[now] = 1;
}
bool vis1[200000] = {};
bool done1[200000] = {};
long long dp1[200000] = {};
void calc_all_path1(long now) {
  vis1[now] = 1;
  dp1[now] = 1;
  for (long long f = (long long)0; f <= (long long)g[now].size() - 1; ++f) {
    if (!vis1[g[now][f]]) {
      calc_all_path1(g[now][f]);
    }
  }
  for (long long f = (long long)0; f <= (long long)g[now].size() - 1; ++f) {
    if (done1[g[now][f]]) {
      dp1[now] += dp1[g[now][f]];
    }
  }
  done1[now] = 1;
}
bool vis2[200000] = {};
void calc_all_path2(long now) {
  vis2[now] = 1;
  for (long long f = (long long)0; f <= (long long)g[now].size() - 1; ++f) {
    if (!vis2[g[now][f]]) {
      all_path += (dp1[0] - dp1[g[now][f]]) * dp1[g[now][f]];
      calc_all_path2(g[now][f]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(15);
  cin >> n >> k;
  for (long long f = (long long)0; f <= (long long)n - 2; ++f) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(0);
  rem[0] -= n;
  calc_all_path1(0);
  calc_all_path2(0);
  long long x = 0;
  for (long long f = (long long)1; f <= (long long)k - 1; ++f) {
    x += rem[f] * (k - f);
  }
  cout << (all_path + x) / k;
  return 0;
}

```