#include <bits/stdc++.h>
using namespace std;
const int N = 356438;
int from[N], to[N], limL, nextp[N], headp[N], p[N], Lcnt[N], chcnt[N], num,
    a[N], b[N], sz, c[N];
bool taboo[N], boo[N];
long long limW, W[N], Wcnt[N], ans;
inline int lowbit(int x) { return x & (-x); }
inline int ask(int x) {
  int ans = 0;
  while (x) {
    ans += c[x];
    x -= lowbit(x);
  }
  return ans;
}
inline void add(int x, int y) {
  while (x < N) {
    c[x] += y;
    x += lowbit(x);
  }
}
inline void addedge(int x, int y, long long z, int &tot) {
  from[tot] = x;
  to[tot] = y;
  W[tot] = z;
  nextp[tot] = headp[x];
  headp[x] = tot;
  ++tot;
}
void dfs(int x) {
  a[sz] = x;
  ++sz;
  chcnt[x] = 1;
  for (int i = headp[x]; i != -1; i = nextp[i]) {
    if (taboo[i]) continue;
    int y = to[i];
    if (p[x] != -1 && from[p[x]] == y) continue;
    p[y] = i;
    dfs(y);
    chcnt[x] += chcnt[y];
  }
}
void dfs2(int x, bool b) {
  boo[x] = b;
  for (int i = headp[x]; i != -1; i = nextp[i]) {
    if (taboo[i]) continue;
    int y = to[i];
    if (p[x] != -1 && from[p[x]] == y) continue;
    p[y] = i;
    Lcnt[y] = Lcnt[x] + 1;
    Wcnt[y] = Wcnt[x] + W[i];
    dfs2(y, b);
  }
}
inline bool cmpb(int x, int y) {
  if (Wcnt[x] != Wcnt[y]) return Wcnt[x] < Wcnt[y];
  if (Lcnt[x] != Lcnt[y]) return Lcnt[x] < Lcnt[y];
  return boo[x] < boo[y];
}
void work(int root) {
  p[root] = -1;
  Lcnt[root] = 0;
  Wcnt[root] = 0;
  sz = 0;
  dfs(root);
  if (sz == 1) return;
  int tempsz = 0, tempedge = -1;
  for (int i = 1; i < sz; ++i) {
    int x = a[i];
    if (min(chcnt[x], sz - chcnt[x]) > tempsz) {
      tempsz = min(chcnt[x], sz - chcnt[x]);
      tempedge = p[x];
    }
  }
  taboo[tempedge] = taboo[tempedge ^ 1] = true;
  Lcnt[from[tempedge]] = 0;
  Wcnt[from[tempedge]] = 0;
  p[from[tempedge]] = -1;
  dfs2(from[tempedge], true);
  Lcnt[to[tempedge]] = 0;
  Wcnt[to[tempedge]] = 0;
  p[to[tempedge]] = -1;
  dfs2(to[tempedge], false);
  for (int i = 0; i < sz; ++i) {
    int x = a[i];
    if (boo[x]) {
      Lcnt[x] = limL - Lcnt[x] - 1;
      Wcnt[x] = limW - Wcnt[x] - W[tempedge];
    }
    b[i] = x;
  }
  sort(b, b + sz, cmpb);
  for (int i = 0; i < sz; ++i) {
    int x = b[i];
    if (boo[x]) {
      if (Lcnt[x] < 0) continue;
      ans += ask(Lcnt[x] + 1);
    } else {
      add(Lcnt[x] + 1, 1);
    }
  }
  for (int i = 0; i < sz; ++i) {
    int x = b[i];
    if (boo[x]) {
    } else {
      add(Lcnt[x] + 1, -1);
    }
  }
  work(to[tempedge]);
  work(from[tempedge]);
}
int main() {
  int n;
  scanf("%d%d%I64d", &n, &limL, &limW);
  int tot = 0;
  memset(headp, -1, sizeof(headp));
  for (int i = 2; i <= n; ++i) {
    int j;
    long long temp;
    scanf("%d %I64d", &j, &temp);
    addedge(i, j, temp, tot);
    addedge(j, i, temp, tot);
  }
  work(1);
  printf("%I64d\n", ans);
}
