#include <bits/stdc++.h>
const int oo = 2139063143;
const int N = 2010000;
const int mod = 1000000007;
using namespace std;
inline void sc(int &x) {
  x = 0;
  static int p;
  p = 1;
  static char c;
  c = getchar();
  while (!isdigit(c)) {
    if (c == '-') p = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c - 48);
    c = getchar();
  }
  x *= p;
}
int n, suml, sumw;
struct EDGE {
  int v, w, nx;
} lb[N << 1];
int tot = 1, top[N];
void add(int u, int v, int w) {
  lb[++tot].v = v, lb[tot].w = w, lb[tot].nx = top[u], top[u] = tot;
}
int siz[N], masiz[N], bs[N];
long long dep[N];
bool vis[N];
int q[N], head, tail;
void dfs(int u) {
  q[++tail] = u;
  siz[u] = vis[u] = 1, masiz[u] = 0;
  vis[u] = 1;
  for (int kb = top[u]; kb != -1; kb = lb[kb].nx) {
    int v = lb[kb].v, w = lb[kb].w;
    if (vis[v]) continue;
    dep[v] = dep[u] + w, bs[v] = bs[u] + 1;
    dfs(v);
    siz[u] += siz[v];
    masiz[u] = max(masiz[u], siz[v]);
  }
  vis[u] = 0;
}
int bit[N];
void add(int w, int d) {
  if (w > suml) return;
  for (; w < N; w += w & -w) bit[w] += d;
}
int sum(int w) {
  if (w > suml || w <= 0) return 0;
  int ans = 0;
  for (; w; w -= w & -w) ans += bit[w];
  return ans;
}
bool ly(int A, int B) { return dep[A] < dep[B]; }
bool sta[N];
long long calc(int l, int r) {
  long long ans = 0;
  sort(q + l, q + r + 1, ly);
  for (int i = l; i <= r; i++) add(bs[q[i]], 1), sta[i] = 1;
  for (int i = l, j = r; i <= j; i++) {
    sta[i] = 0, add(bs[q[i]], -1);
    while (i < j && dep[q[i]] + dep[q[j]] > sumw)
      sta[j] = 0, add(bs[q[j--]], -1);
    if (i == j) break;
    ans += sum(suml - bs[q[i]]);
  }
  for (int i = l; i <= r; i++)
    if (sta[i]) add(q[i], -1), sta[i] = 0;
  return ans;
}
long long ans = 0;
void work(int u) {
  head = 1, tail = 0;
  dfs(u);
  int t = siz[u], mi = masiz[u];
  for (int i = 1; i <= tail; i++) {
    int v = q[i];
    int mm = max(masiz[v], t - siz[v]);
    if (mm < mi) mi = mm, u = v;
  }
  vis[u] = 1;
  head = 1, tail = 0;
  for (int kb = top[u]; kb != -1; kb = lb[kb].nx) {
    int v = lb[kb].v, w = lb[kb].w;
    if (vis[v]) continue;
    dep[v] = w, bs[v] = 1;
    dfs(v);
    ans -= calc(head, tail);
    head = tail + 1;
  }
  ans += calc(1, tail);
  for (int i = 1; i <= tail; i++)
    if (bs[q[i]] <= suml && dep[q[i]] <= sumw) ++ans;
  for (int kb = top[u]; kb != -1; kb = lb[kb].nx) {
    int v = lb[kb].v;
    if (vis[v]) continue;
    work(v);
  }
}
int main() {
  memset(top, -1, sizeof(top));
  sc(n), sc(suml), sc(sumw);
  for (int i = 2; i <= n; i++) {
    int p, w;
    sc(p), sc(w);
    add(i, p, w), add(p, i, w);
  }
  work(1);
  printf("%lld\n", ans);
  return 0;
}
