#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
struct ha {
  int v, w;
};
struct node {
  int dis, dep;
} s[N];
int n, m, k, dis[N], vis[N], sum, size[N], dep[N], f[N], rt, cnt, c[N];
long long ans;
vector<ha> q[N];
void add(int x, int y) {
  if (!x) return;
  while (x <= n + 1) {
    c[x] += y;
    x += x & -x;
  }
}
int Sum(int x) {
  if (x <= 0) return 0;
  int res = 0;
  while (x) {
    res += c[x];
    x -= x & -x;
  }
  return res;
}
bool cmp(node a, node b) { return a.dis < b.dis; }
void getroot(int u, int fa) {
  size[u] = 1;
  f[u] = 0;
  for (int i = 0; i < q[u].size(); i++) {
    int v = q[u][i].v;
    if (vis[v] || v == fa) continue;
    getroot(v, u);
    size[u] += size[v];
    f[u] = max(f[u], size[v]);
  }
  f[u] = max(f[u], sum - size[u]);
  if (f[u] < f[rt]) rt = u;
}
void dfs(int u, int fa) {
  s[++cnt] = (node){dis[u], dep[u]};
  for (int i = 0; i < q[u].size(); i++) {
    int v = q[u][i].v, w = q[u][i].w;
    if (v == fa || vis[v]) continue;
    dis[v] = dis[u] + w;
    dep[v] = dep[u] + 1;
    dfs(v, u);
  }
}
long long calc(int u, int Dis, int Dep) {
  cnt = 0;
  dis[u] = Dis;
  dep[u] = Dep;
  dfs(u, 0);
  sort(s + 1, s + cnt + 1, cmp);
  for (int i = 1; i <= cnt; i++) add(s[i].dep + 1, 1);
  int l = 1, r = cnt;
  long long res = 0;
  while (l < r) {
    if (s[l].dis + s[r].dis <= k) {
      add(s[l].dep + 1, -1);
      res += Sum(m - s[l].dep + 1);
      l++;
    } else {
      add(s[r].dep + 1, -1);
      r--;
    }
  }
  add(s[l].dep + 1, -1);
  return res;
}
void solve(int u) {
  ans += calc(u, 0, 0);
  vis[u] = 1;
  for (int i = 0; i < q[u].size(); i++) {
    int v = q[u][i].v;
    if (vis[v]) continue;
    ans -= calc(v, q[u][i].w, 1);
    rt = 0;
    sum = size[v];
    getroot(v, 0);
    solve(rt);
  }
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i < n; i++) {
    int p, w;
    cin >> p >> w;
    q[i + 1].push_back((ha){p, w});
    q[p].push_back((ha){i + 1, w});
  }
  f[rt] = sum = n;
  getroot(1, 0);
  solve(rt);
  cout << ans;
  return 0;
}
