#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;
}
