#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
long long n, m, nn, cnt, tot, k, k_, x, y, ww, rt, ans;
long long to[N], nextn[N], h[N];
long long mxsize[N], size[N];
long long w[N];
struct dis {
  long long d, d_;
  bool operator<(const dis &x) const { return x.d > d; }
} tmp[N], q[N], q0[N];
long long t[N];
bool b[N];
long long lowbit(long long x) { return x & (-x); }
void update(long long x, long long v) {
  for (long long i = x; i <= n; i += lowbit(i)) t[i] += v;
}
long long inquiry(long long x) {
  long long res = 0;
  for (long long i = x; i; i -= lowbit(i)) res += t[i];
  return res;
}
void add(long long x, long long y, long long ww) {
  cnt++;
  to[cnt] = y;
  nextn[cnt] = h[x];
  h[x] = cnt;
  w[cnt] = ww;
}
void findrt(long long x, long long anc) {
  mxsize[x] = 0;
  size[x] = 1;
  for (long long i = h[x]; i; i = nextn[i]) {
    long long y = to[i];
    if (y == anc || b[y]) continue;
    findrt(y, x);
    size[x] += size[y];
    mxsize[x] = max(mxsize[x], size[y]);
  }
  mxsize[x] = max(mxsize[x], nn - size[x]);
  if (mxsize[x] < mxsize[rt]) rt = x;
}
void dfs(long long x, long long anc, long long dis1, long long dis_) {
  tmp[++tot] = (dis){dis1, dis_};
  if (dis1 <= k && dis_ <= k_) ans++;
  for (long long i = h[x]; i; i = nextn[i]) {
    long long y = to[i];
    if (y == anc || b[y]) continue;
    dfs(y, x, dis1 + w[i], dis_ + 1);
  }
}
void work(long long x) {
  cnt = 0;
  for (long long i = h[x]; i; i = nextn[i]) {
    long long y = to[i];
    if (b[y]) continue;
    tot = 0;
    dfs(y, x, w[i], 1);
    sort(tmp + 1, tmp + tot + 1);
    long long last = 0;
    for (long long j = tot; j >= 1; j--)
      if (tmp[j].d < k && tmp[j].d_ < k_) {
        long long pos =
            lower_bound(q + 1, q + cnt + 1, dis{k - tmp[j].d + 1, 0}) - q;
        while (q[pos].d > k - tmp[j].d) pos--;
        for (long long l = last + 1; l <= pos && l <= cnt; l++)
          update(q[l].d_, 1);
        ans += inquiry(k_ - tmp[j].d_);
        last = pos;
      }
    for (long long l = 1; l <= last && l <= cnt; l++) update(q[l].d_, -1);
    merge(tmp + 1, tmp + tot + 1, q + 1, q + cnt + 1, q0 + 1);
    cnt += tot;
    for (long long i = 1; i <= cnt; i++) q[i] = q0[i];
  }
}
void solve(long long x) {
  b[x] = 1;
  work(x);
  for (long long i = h[x]; i; i = nextn[i]) {
    long long y = to[i];
    if (b[y]) continue;
    rt = 0, mxsize[0] = n;
    nn = size[y];
    findrt(y, x);
    solve(rt);
  }
}
signed main() {
  scanf("%lld%lld%lld", &n, &k_, &k);
  for (long long i = 1; i < n; i++) {
    scanf("%lld%lld", &y, &ww);
    add(i + 1, y, ww), add(y, i + 1, ww);
  }
  rt = 0, nn = n;
  mxsize[0] = n;
  findrt(1, 0);
  solve(rt);
  printf("%lld", ans);
}
