#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
using ll = long long;
int n, m, kk, a[N][2], fa[N], sz[N], dep[N], top[N], hson[N], f1[N];
vector<int> v[N], b[N];
map<int, map<int, int>> f2[N];
ll ans;
void dfs1(int pos) {
  dep[pos] = dep[fa[pos]] + 1;
  sz[pos] = 1;
  for (auto &i : v[pos])
    if (i != fa[pos]) {
      fa[i] = pos;
      dfs1(i);
      sz[pos] += sz[i];
      if (sz[i] > sz[hson[pos]]) hson[pos] = i;
    }
}
void dfs2(int pos, int tp) {
  top[pos] = tp;
  b[top[pos]].push_back(pos);
  if (hson[pos]) dfs2(hson[pos], tp);
  for (auto &i : v[pos])
    if (i != fa[pos] && i != hson[pos]) dfs2(i, i);
}
int lca(int a, int b) {
  while (top[a] != top[b]) {
    if (dep[top[a]] < dep[top[b]]) swap(a, b);
    a = fa[top[a]];
  }
  return dep[a] < dep[b] ? a : b;
}
int go(int x, int kk) {
  int len = dep[x] - dep[top[x]];
  if (len < kk) return go(fa[top[x]], kk - len - 1);
  return b[top[x]][len - kk];
}
int q1[N], q2[N];
int add1(int x, int y) {
  int len = dep[x] - dep[y];
  if (len < kk) return x;
  int z = go(x, len - kk + 1);
  ++f1[x];
  --f1[z];
  return z;
}
void add2(int u1, int u2, int v1, int v2) {
  if (top[u1] > top[v1]) swap(u1, v1), swap(u2, v2);
  if (dep[u1] > dep[u2]) swap(u1, u2);
  ++f2[top[u1]][top[v1]][dep[u1]];
  --f2[top[u1]][top[v1]][dep[u2] + 1];
}
void add(int x, int y) {
  int z = lca(x, y);
  x = add1(x, z);
  y = add1(y, z);
  int u = x, v = y, n1 = 0, n2 = 0;
  while (top[u] != top[z]) q1[++n1] = u, u = fa[top[u]];
  while (top[v] != top[z]) q2[++n2] = v, v = fa[top[v]];
  if (u != z) q1[++n1] = u;
  if (v != z) q2[++n2] = v;
  for (int i1 = 1, i2 = n2; i1 <= n1; ++i1) {
    int u1 = q1[i1], u2 = top[u1];
    if (dep[u2] <= dep[z]) u2 = hson[z];
    while (i2) {
      int v1 = q2[i2], v2 = top[v1];
      if (dep[v2] <= dep[z]) v2 = hson[z];
      if (dep[u1] + dep[v1] - dep[z] * 2 < kk) {
        --i2;
        continue;
      }
      int len = dep[u1] + dep[v1] - dep[z] * 2, w1 = go(v1, len - kk), w2 = 0;
      len = dep[u2] + dep[v1] - dep[z] * 2;
      if (len >= kk) {
        w2 = go(v1, len - kk);
        add2(u1, u2, w1, w2);
        break;
      }
      len = dep[u1] + dep[v1] - dep[z] * 2;
      w2 = go(u1, len - kk);
      add2(u1, w2, w1, v1);
      u1 = fa[w2];
      --i2;
    }
  }
}
ll C2(ll x) { return x * (x - 1) / 2; }
void dfs3(int pos, int t) {
  for (auto &i : v[pos])
    if (i != fa[pos]) dfs3(i, t), f1[pos] += f1[i];
  ans += C2(f1[pos]) * t;
}
void calc(int t) {
  for (int i = 1; i <= n; f2[i++].clear())
    for (auto &j : f2[i]) {
      ll sum = 0, lst = 0;
      for (auto &k : j.second)
        ans += (k.first - lst) * C2(sum) * t, lst = k.first, sum += k.second;
    }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> kk;
  for (int i = 1; i < n; i++) {
    int t1, t2;
    cin >> t1 >> t2;
    v[t1].push_back(t2);
    v[t2].push_back(t1);
  }
  dfs1(1);
  dfs2(1, 1);
  for (int i = 1; i <= m; i++) cin >> a[i][0] >> a[i][1], add(a[i][0], a[i][1]);
  dfs3(1, 1);
  calc(1);
  memset(f1, 0, sizeof(f1));
  ++kk;
  for (int i = 1; i <= m; i++) add(a[i][0], a[i][1]);
  dfs3(1, -1);
  calc(-1);
  cout << ans << endl;
  return 0;
}
