#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T BM(T p, T e, T M) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T mdINV(T a, T M) {
  return BM(a, M - 2, M);
}
template <class T>
inline T PW(T p, T e) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p);
    p = (p * p);
  }
  return (T)ret;
}
template <class T>
string NTS(T Number) {
  stringstream ss;
  ss << Number;
  return ss.str();
}
template <class T>
T stringtonumber(const string &Text) {
  istringstream ss(Text);
  T result;
  return ss >> result ? result : 0;
}
template <class T>
bool ISLEFT(T a, T b, T c) {
  if (((a.first.first - b.first.first) * (b.second.second - c.second.second) -
       (b.first.first - c.first.first) * (a.second.second - b.second.second)) <
      0.0)
    return 1;
  else
    return 0;
}
vector<int> adj[200002ll];
bool del[200002ll];
int subTree[200002ll];
int par[200002ll];
long long int dis[22][200002ll];
int L[200002ll];
int n, k;
int tot;
void Dfs(int u, int p) {
  subTree[u] = 1;
  tot++;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == p) continue;
    if (del[v]) continue;
    Dfs(v, u);
    subTree[u] += subTree[v];
  }
}
int GetCenter(int u, int p) {
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == p) continue;
    if (del[v]) continue;
    if (subTree[v] > tot / 2) return GetCenter(v, u);
  }
  return u;
}
long long int re[19][200002ll][5];
long long int ro[19][200002ll];
long long int re1[2][200002ll + 2][6];
long long int ro1[2][200002ll + 2];
void SetDis(int u, int p, int l, int f, int ce) {
  dis[f][u] = l;
  re[f][u][l % k]++;
  ro[f][u] += (l / k);
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == p) continue;
    if (del[v]) continue;
    SetDis(v, u, l + 1, f, ce);
    ro[f][u] += ro[f][v];
    for (int j = 0; j < k; j++) {
      re[f][u][j] += re[f][v][j];
    }
  }
}
void Decompose(int u, int p, int l, int ce) {
  int center = ce;
  SetDis(center, -1, 0, l, center);
  par[center] = p;
  del[center] = 1;
  L[center] = l;
  ro1[0][center] = ro[l][center];
  for (int i = 0; i <= k - 1; i++) re1[0][center][i] = re[l][center][i];
  for (int i = 0; i < adj[center].size(); i++) {
    int v = adj[center][i];
    if (del[v]) continue;
    tot = 0;
    Dfs(v, -1);
    int cech = GetCenter(v, -1);
    ro1[1][cech] = ro[l][v];
    for (int j = 0; j <= k - 1; j++) re1[1][cech][j] = re[l][v][j];
    Decompose(v, center, l + 1, cech);
  }
}
long long int Query(int u) {
  int v = u;
  int l = L[u];
  long long int res = 0;
  res += ro1[0][u];
  for (int i = 1; i <= k - 1; i++) {
    res += re1[0][u][i];
  }
  long long int are[6];
  while (par[u] != -1) {
    int first = u;
    u = par[u];
    l = L[u];
    long long int dist = dis[l][first];
    res += ro1[0][u] - ro1[1][first];
    for (int i = 0; i <= k - 1; i++) {
      are[i] = re1[0][u][i] - re1[1][first][i];
    }
    dist = dis[l][v];
    for (int i = 0; i <= k - 1; i++) {
      long long int xo = (i + dist + k - 1) / k;
      res += xo * are[i];
    }
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n - 1; i++) {
    int first, second;
    scanf("%d%d", &first, &second);
    adj[first].push_back(second);
    adj[second].push_back(first);
  }
  tot = 0;
  Dfs(1, -1);
  int first = GetCenter(1, -1);
  Decompose(1, -1, 0, first);
  long long int an = 0;
  for (int i = 1; i <= n; i++) {
    an += Query(i);
  }
  printf("%lld", an / 2), printf("\n");
  return 0;
}

### Prompt

Your task is to create 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;
template <class T>
inline T BM(T p, T e, T M) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T mdINV(T a, T M) {
  return BM(a, M - 2, M);
}
template <class T>
inline T PW(T p, T e) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p);
    p = (p * p);
  }
  return (T)ret;
}
template <class T>
string NTS(T Number) {
  stringstream ss;
  ss << Number;
  return ss.str();
}
template <class T>
T stringtonumber(const string &Text) {
  istringstream ss(Text);
  T result;
  return ss >> result ? result : 0;
}
template <class T>
bool ISLEFT(T a, T b, T c) {
  if (((a.first.first - b.first.first) * (b.second.second - c.second.second) -
       (b.first.first - c.first.first) * (a.second.second - b.second.second)) <
      0.0)
    return 1;
  else
    return 0;
}
vector<int> adj[200002ll];
bool del[200002ll];
int subTree[200002ll];
int par[200002ll];
long long int dis[22][200002ll];
int L[200002ll];
int n, k;
int tot;
void Dfs(int u, int p) {
  subTree[u] = 1;
  tot++;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == p) continue;
    if (del[v]) continue;
    Dfs(v, u);
    subTree[u] += subTree[v];
  }
}
int GetCenter(int u, int p) {
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == p) continue;
    if (del[v]) continue;
    if (subTree[v] > tot / 2) return GetCenter(v, u);
  }
  return u;
}
long long int re[19][200002ll][5];
long long int ro[19][200002ll];
long long int re1[2][200002ll + 2][6];
long long int ro1[2][200002ll + 2];
void SetDis(int u, int p, int l, int f, int ce) {
  dis[f][u] = l;
  re[f][u][l % k]++;
  ro[f][u] += (l / k);
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == p) continue;
    if (del[v]) continue;
    SetDis(v, u, l + 1, f, ce);
    ro[f][u] += ro[f][v];
    for (int j = 0; j < k; j++) {
      re[f][u][j] += re[f][v][j];
    }
  }
}
void Decompose(int u, int p, int l, int ce) {
  int center = ce;
  SetDis(center, -1, 0, l, center);
  par[center] = p;
  del[center] = 1;
  L[center] = l;
  ro1[0][center] = ro[l][center];
  for (int i = 0; i <= k - 1; i++) re1[0][center][i] = re[l][center][i];
  for (int i = 0; i < adj[center].size(); i++) {
    int v = adj[center][i];
    if (del[v]) continue;
    tot = 0;
    Dfs(v, -1);
    int cech = GetCenter(v, -1);
    ro1[1][cech] = ro[l][v];
    for (int j = 0; j <= k - 1; j++) re1[1][cech][j] = re[l][v][j];
    Decompose(v, center, l + 1, cech);
  }
}
long long int Query(int u) {
  int v = u;
  int l = L[u];
  long long int res = 0;
  res += ro1[0][u];
  for (int i = 1; i <= k - 1; i++) {
    res += re1[0][u][i];
  }
  long long int are[6];
  while (par[u] != -1) {
    int first = u;
    u = par[u];
    l = L[u];
    long long int dist = dis[l][first];
    res += ro1[0][u] - ro1[1][first];
    for (int i = 0; i <= k - 1; i++) {
      are[i] = re1[0][u][i] - re1[1][first][i];
    }
    dist = dis[l][v];
    for (int i = 0; i <= k - 1; i++) {
      long long int xo = (i + dist + k - 1) / k;
      res += xo * are[i];
    }
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n - 1; i++) {
    int first, second;
    scanf("%d%d", &first, &second);
    adj[first].push_back(second);
    adj[second].push_back(first);
  }
  tot = 0;
  Dfs(1, -1);
  int first = GetCenter(1, -1);
  Decompose(1, -1, 0, first);
  long long int an = 0;
  for (int i = 1; i <= n; i++) {
    an += Query(i);
  }
  printf("%lld", an / 2), printf("\n");
  return 0;
}

```