#include <bits/stdc++.h>
using namespace std;
const long long mod0 = 1e9 + 7;
const long long mod1 = 998244353;
const long long mod2 = 1e9 + 9;
const long long mod3 = 2147483647;
const int maxn = 1e5 + 3;
const long long inf = 2 * 1024 * 1024 * 1023 - 1;
const long long INF = inf * inf;
const long double eps = 1e-7;
void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(16);
}
int n, L, W;
vector<int> first(maxn), nd(maxn), sz(100001), msz(100001), v(100001),
    d1(100010), d2(100001), dv(100001);
vector<int> nxt(2 * maxn), to(2 * maxn), from(2 * maxn);
int idx, num;
long long ans;
void add(int x, int y, int p) {
  nxt[++idx] = first[x];
  first[x] = idx;
  to[idx] = y;
  from[idx] = p;
  nxt[++idx] = first[y];
  first[y] = idx;
  to[idx] = x;
  from[idx] = p;
}
void insert(int x, int p) {
  for (++x; x <= n + 1; x += x & -x) v[x] += p;
}
int ask(int x) {
  int result = 0;
  for (++x; x; x -= x & -x) result += v[x];
  return result;
}
void dfs(int x, int pr) {
  sz[x] = 1;
  msz[x] = 0;
  for (int i = first[x]; i > 0; i = nxt[i]) {
    if (dv[to[i]]) continue;
    if (to[i] != pr) {
      d1[to[i]] = d1[x] + 1;
      d2[to[i]] = d2[x] + from[i];
      dfs(to[i], x);
      sz[x] += sz[to[i]];
      msz[x] = max(msz[x], sz[to[i]]);
    }
  }
  nd[++num] = x;
}
bool cmp(int x, int y) { return d2[x] < d2[y]; }
void getans(int z) {
  vector<int> nd1(num);
  for (int i = 1; i <= num; ++i) nd1[i - 1] = nd[i];
  sort(nd1.begin(), nd1.end(), cmp);
  for (int i = 1; i <= num; ++i) nd[i] = nd1[i - 1];
  int j = 0;
  for (int i = num; i > 0; --i) {
    while (j < num && d2[nd[i]] + d2[nd[j + 1]] <= W) {
      insert(d1[nd[++j]], 1);
    }
    if (d1[nd[i]] <= L) ans += z * ask(L - d1[nd[i]]);
  }
  while (j > 0) insert(d1[nd[j--]], -1);
}
void solve(int x) {
  num = 0;
  dfs(x, -1);
  int N = sz[x], rt = x;
  for (int i = 1; i <= num; i++) {
    if (max(msz[rt], N - msz[rt]) > max(msz[nd[i]], N - msz[nd[i]])) rt = nd[i];
  }
  num = 0;
  d1[rt] = d2[rt] = 0;
  dv[rt] = true;
  dfs(rt, -1);
  getans(1);
  for (int i = first[rt]; i > 0; i = nxt[i]) {
    if (dv[to[i]]) continue;
    num = 0;
    dfs(to[i], -1);
    getans(-1);
  }
  for (int i = first[rt]; i > 0; i = nxt[i]) {
    if (dv[to[i]]) continue;
    solve(to[i]);
  }
}
int main() {
  init();
  cin >> n >> L >> W;
  for (int i = 1; i < n; i++) {
    int p0, w0;
    cin >> p0 >> w0;
    add(p0, i + 1, w0);
  }
  solve(1);
  cout << ((ans - n) / 2) << endl;
}
