#include <bits/stdc++.h>
using namespace std;
struct debugger {
  template <typename T>
  debugger &operator,(const T &v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
inline long long gcd(long long a, long long b) {
  a = ((a) < 0 ? -(a) : (a));
  b = ((b) < 0 ? -(b) : (b));
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
long long ext_gcd(long long A, long long B, long long *X, long long *Y) {
  long long x2, y2, x1, y1, x, y, r2, r1, q, r;
  x2 = 1;
  y2 = 0;
  x1 = 0;
  y1 = 1;
  for (r2 = A, r1 = B; r1 != 0;
       r2 = r1, r1 = r, x2 = x1, y2 = y1, x1 = x, y1 = y) {
    q = r2 / r1;
    r = r2 % r1;
    x = x2 - (q * x1);
    y = y2 - (q * y1);
  }
  *X = x2;
  *Y = y2;
  return r2;
}
inline long long modInv(long long a, long long m) {
  long long x, y;
  ext_gcd(a, m, &x, &y);
  x %= m;
  if (x < 0) x += m;
  return x;
}
inline long long power(long long a, long long p) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x);
    x = (x * x);
    p >>= 1;
  }
  return res;
}
inline long long bigmod(long long a, long long p, long long m) {
  long long res = 1 % m, x = a % m;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
inline int STRLEN(char *s) {
  int p = 0;
  while (s[p]) p++;
  return p;
}
inline long long SQRT(long long a) {
  long long v = sqrt(a);
  if (((v) * (v)) == a)
    return v;
  else if (((v + 1) * (v + 1)) == a)
    return v + 1;
  else if (((v + 2) * (v + 2)) == a)
    return v + 2;
  else
    return -1;
}
const long long inf = 100000000000000000LL;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
const int Size = 200005;
long long N, K;
long long ans = 0, szz = 0, len = 0;
const int LOGN = 25;
set<int> Graph[Size];
long long sz[Size];
long long ndist[LOGN][10];
long long CC[LOGN][10];
void getSize(int u, int p) {
  sz[u] = 1;
  szz++;
  for (auto it = Graph[u].begin(); it != Graph[u].end(); it++) {
    int v = *it;
    if (v != p) {
      getSize(*it, u), sz[u] += sz[v];
    }
  }
}
int getCenter(int u, int p) {
  for (auto it = Graph[u].begin(); it != Graph[u].end(); it++) {
    int v = *it;
    if (v != p && sz[v] > szz / 2) {
      return getCenter(*it, u);
    }
  }
  return u;
}
long long bestMove(long long sum) {
  long long mv = sum / K;
  if (sum % K != 0) mv++;
  return mv;
}
void updateSubtree(int u, int p, int level, long long sum, int add) {
  if (sum != 0) {
    long long mv = bestMove(sum);
    long long ext = mv * K - sum;
    ndist[level][ext] += (mv * add);
    CC[level][ext] += add;
  }
  for (auto it = Graph[u].begin(); it != Graph[u].end(); it++) {
    int v = *it;
    if (v != p) {
      updateSubtree(v, u, level, sum + 1, add);
    }
  }
}
long long findRes(int u, int p, int level, int sum) {
  long long ret = 0;
  ret += 2LL * bestMove(sum);
  long long mv = sum / K;
  long long nd = sum - mv * K;
  for (int ext = nd; ext < K; ext++) {
    ret += ndist[level][ext];
    ret += (mv * CC[level][ext]);
  }
  for (int ext = 0; ext < nd; ext++) {
    ret += ndist[level][ext];
    ret += ((mv + 1) * CC[level][ext]);
  }
  for (auto it = Graph[u].begin(); it != Graph[u].end(); it++) {
    int v = *it;
    if (v != p) {
      ret += findRes(v, u, level, sum + 1);
    }
  }
  return ret;
}
void decompose(int root, int level) {
  szz = 0;
  getSize(root, root);
  int centroid = getCenter(root, root);
  updateSubtree(centroid, centroid, level, 0, 1);
  long long add = 0;
  int u = centroid;
  for (auto it = Graph[u].begin(); it != Graph[u].end(); it++) {
    int v = *it;
    updateSubtree(v, u, level, 1, -1);
    add += findRes(v, u, level, 1);
    updateSubtree(v, u, level, 1, 1);
  }
  ans += add / 2LL;
  for (auto it = Graph[u].begin(); it != Graph[u].end(); it++) {
    int v = *it;
    Graph[v].erase(u);
    decompose(v, level + 1);
  }
  for (int i = 0; i <= K; i++) {
    ndist[level][i] = 0;
    CC[level][i] = 0;
  }
}
int main() {
  int a, b;
  scanf("%lld %lld", &N, &K);
  memset(ndist, 0, sizeof(ndist));
  memset(CC, 0, sizeof(CC));
  for (int i = 0; i < N - 1; i++) {
    scanf("%d %d", &a, &b);
    a--;
    b--;
    Graph[a].insert(b);
    Graph[b].insert(a);
  }
  decompose(0, 0);
  cout << ans << endl;
  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 debugger {
  template <typename T>
  debugger &operator,(const T &v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
inline long long gcd(long long a, long long b) {
  a = ((a) < 0 ? -(a) : (a));
  b = ((b) < 0 ? -(b) : (b));
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
long long ext_gcd(long long A, long long B, long long *X, long long *Y) {
  long long x2, y2, x1, y1, x, y, r2, r1, q, r;
  x2 = 1;
  y2 = 0;
  x1 = 0;
  y1 = 1;
  for (r2 = A, r1 = B; r1 != 0;
       r2 = r1, r1 = r, x2 = x1, y2 = y1, x1 = x, y1 = y) {
    q = r2 / r1;
    r = r2 % r1;
    x = x2 - (q * x1);
    y = y2 - (q * y1);
  }
  *X = x2;
  *Y = y2;
  return r2;
}
inline long long modInv(long long a, long long m) {
  long long x, y;
  ext_gcd(a, m, &x, &y);
  x %= m;
  if (x < 0) x += m;
  return x;
}
inline long long power(long long a, long long p) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x);
    x = (x * x);
    p >>= 1;
  }
  return res;
}
inline long long bigmod(long long a, long long p, long long m) {
  long long res = 1 % m, x = a % m;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
inline int STRLEN(char *s) {
  int p = 0;
  while (s[p]) p++;
  return p;
}
inline long long SQRT(long long a) {
  long long v = sqrt(a);
  if (((v) * (v)) == a)
    return v;
  else if (((v + 1) * (v + 1)) == a)
    return v + 1;
  else if (((v + 2) * (v + 2)) == a)
    return v + 2;
  else
    return -1;
}
const long long inf = 100000000000000000LL;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
const int Size = 200005;
long long N, K;
long long ans = 0, szz = 0, len = 0;
const int LOGN = 25;
set<int> Graph[Size];
long long sz[Size];
long long ndist[LOGN][10];
long long CC[LOGN][10];
void getSize(int u, int p) {
  sz[u] = 1;
  szz++;
  for (auto it = Graph[u].begin(); it != Graph[u].end(); it++) {
    int v = *it;
    if (v != p) {
      getSize(*it, u), sz[u] += sz[v];
    }
  }
}
int getCenter(int u, int p) {
  for (auto it = Graph[u].begin(); it != Graph[u].end(); it++) {
    int v = *it;
    if (v != p && sz[v] > szz / 2) {
      return getCenter(*it, u);
    }
  }
  return u;
}
long long bestMove(long long sum) {
  long long mv = sum / K;
  if (sum % K != 0) mv++;
  return mv;
}
void updateSubtree(int u, int p, int level, long long sum, int add) {
  if (sum != 0) {
    long long mv = bestMove(sum);
    long long ext = mv * K - sum;
    ndist[level][ext] += (mv * add);
    CC[level][ext] += add;
  }
  for (auto it = Graph[u].begin(); it != Graph[u].end(); it++) {
    int v = *it;
    if (v != p) {
      updateSubtree(v, u, level, sum + 1, add);
    }
  }
}
long long findRes(int u, int p, int level, int sum) {
  long long ret = 0;
  ret += 2LL * bestMove(sum);
  long long mv = sum / K;
  long long nd = sum - mv * K;
  for (int ext = nd; ext < K; ext++) {
    ret += ndist[level][ext];
    ret += (mv * CC[level][ext]);
  }
  for (int ext = 0; ext < nd; ext++) {
    ret += ndist[level][ext];
    ret += ((mv + 1) * CC[level][ext]);
  }
  for (auto it = Graph[u].begin(); it != Graph[u].end(); it++) {
    int v = *it;
    if (v != p) {
      ret += findRes(v, u, level, sum + 1);
    }
  }
  return ret;
}
void decompose(int root, int level) {
  szz = 0;
  getSize(root, root);
  int centroid = getCenter(root, root);
  updateSubtree(centroid, centroid, level, 0, 1);
  long long add = 0;
  int u = centroid;
  for (auto it = Graph[u].begin(); it != Graph[u].end(); it++) {
    int v = *it;
    updateSubtree(v, u, level, 1, -1);
    add += findRes(v, u, level, 1);
    updateSubtree(v, u, level, 1, 1);
  }
  ans += add / 2LL;
  for (auto it = Graph[u].begin(); it != Graph[u].end(); it++) {
    int v = *it;
    Graph[v].erase(u);
    decompose(v, level + 1);
  }
  for (int i = 0; i <= K; i++) {
    ndist[level][i] = 0;
    CC[level][i] = 0;
  }
}
int main() {
  int a, b;
  scanf("%lld %lld", &N, &K);
  memset(ndist, 0, sizeof(ndist));
  memset(CC, 0, sizeof(CC));
  for (int i = 0; i < N - 1; i++) {
    scanf("%d %d", &a, &b);
    a--;
    b--;
    Graph[a].insert(b);
    Graph[b].insert(a);
  }
  decompose(0, 0);
  cout << ans << endl;
  return 0;
}

```