30 30 10
6 1
8 27
5 1
21 6
24 15
12 5
29 7
22 7
23 17
2 13
23 11
29 6
14 18
29 16
27 25
15 2
27 4
19 30
28 19
17 2
27 16
3 4
9 25
19 16
10 16
18 17
26 11
2 27
16 20
13 23
1 4
27 7
6 20
17 30
1 18
2 17
1 11
5 9
25 13
11 20
14 25
30 21
6 24
12 2
25 12
22 13
10 27
24 29
19 24
28 29
24 23
9 6
12 15
11 15
23 14
12 28
28 25
2 11
19 30
 2 2 1
1 2
2 1
1 2

0 1
#include <bits/stdc++.h>
using namespace std;
vector<int> from[150010];
int fa[150010][18], id[150010], TOT, sz[150010], dep[150010], QRY;
int mul[1000010], val[1000000];
vector<pair<int, int> > qry[150010];
vector<int> a[150010];
vector<pair<pair<int, int>, pair<int, int> > > all[150010];
vector<pair<int, int> > rub;
int n;
long long ans;
int T[150010];
void modify(int x, int v) {
  while (x <= n) T[x] += v, x += x & -x;
}
int query(int x) {
  int res = 0;
  while (x) res += T[x], x -= x & -x;
  return res;
}
long long F(int x) { return 1ll * x * (x - 1) / 2; }
void dfs(int x, int last) {
  id[x] = ++TOT, sz[x] = 1, fa[x][0] = last;
  for (int i = 0; i < from[x].size(); i++) {
    int v = from[x][i];
    if (v == last) continue;
    dep[v] = dep[x] + 1, dfs(v, x), sz[x] += sz[v];
  }
}
void get_fa() {
  for (int j = 1; j < 18; j++) {
    for (int i = 1; i <= n; i++) {
      fa[i][j] = fa[fa[i][j - 1]][j - 1];
    }
  }
}
int get_lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  int tmp = dep[x] - dep[y], cnt = 0;
  while (tmp) {
    if (tmp & 1) x = fa[x][cnt];
    tmp >>= 1, cnt++;
  }
  if (x == y) return x;
  for (int i = 17; i >= 0; i--) {
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  }
  return fa[x][0];
}
int get_par(int x, int tmp) {
  int cnt = 0;
  while (tmp) {
    if (tmp & 1) x = fa[x][cnt];
    tmp >>= 1, cnt++;
  }
  return x;
}
void solve(int K, int flag) {
  for (int i = 1; i <= n; i++) {
    if (dep[i] >= K) {
      int x = get_par(i, K - 1);
      int l = id[i], r = id[i] + sz[i] - 1, L = id[x] + sz[x], R = n;
      qry[id[x] - 1].push_back(make_pair(-(l - 1), QRY));
      qry[id[x] - 1].push_back(make_pair(r, QRY));
      qry[l - 1].push_back(make_pair(L - 1, QRY));
      qry[l - 1].push_back(make_pair(-R, QRY));
      qry[r].push_back(make_pair(-(L - 1), QRY));
      qry[r].push_back(make_pair(R, QRY));
      mul[QRY] = flag, QRY++;
    }
    for (int j = 0; j < all[i].size(); j++) {
      int k = j;
      rub.clear();
      while (k < all[i].size() && all[i][j].first == all[i][k].first) {
        int x = all[i][k].second.first, y = all[i][k].second.second;
        int l = max(1, K - y), r = min(K - 1, x);
        if (l <= r)
          rub.push_back(make_pair(l, 1)), rub.push_back(make_pair(r + 1, -1));
        k++;
      }
      sort(rub.begin(), rub.end());
      int cur = 0;
      for (int i = 0; i + 1 < rub.size(); i++) {
        cur += rub[i].second;
        ans += (rub[i + 1].first - rub[i].first) * F(cur) * flag;
      }
      j = k - 1;
    }
  }
}
int main() {
  int k, m;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    from[x].push_back(y);
    from[y].push_back(x);
  }
  dfs(1, 1), get_fa();
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int lca = get_lca(x, y);
    if (x != lca && y != lca) {
      pair<int, int> t1 = make_pair(get_par(x, dep[x] - dep[lca] - 1),
                                    get_par(y, dep[y] - dep[lca] - 1));
      pair<int, int> t2 = make_pair(dep[x] - dep[lca], dep[y] - dep[lca]);
      if (t1.first > t1.second)
        swap(t1.first, t1.second), swap(t2.first, t2.second);
      all[lca].push_back(make_pair(t1, t2));
    }
    x = id[x], y = id[y];
    if (x > y) swap(x, y);
    a[x].push_back(y);
  }
  for (int i = 1; i <= n; i++) {
    sort(all[i].begin(), all[i].end());
  }
  solve(k, 1), solve(k + 1, -1);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < a[i].size(); j++) {
      modify(a[i][j], 1);
    }
    for (int j = 0; j < qry[i].size(); j++) {
      int x = qry[i][j].first;
      if (x >= 0)
        val[qry[i][j].second] += query(x);
      else
        val[qry[i][j].second] -= query(-x);
    }
  }
  for (int i = 0; i < QRY; i++) {
    ans += F(val[i]) * mul[i];
  }
  printf("%I64d\n", ans);
  return 0;
}
