Problem: You've got a weighted tree, consisting of n vertices. Each edge has a non-negative weight. The length of the path between any two vertices of the tree is the number of edges in the path. The weight of the path is the total weight of all edges it contains. 

Two vertices are close if there exists a path of length at most l between them and a path of weight at most w between them. Count the number of pairs of vertices v, u (v < u), such that vertices v and u are close.

Input

The first line contains three integers n, l and w (1 ≤ n ≤ 105, 1 ≤ l ≤ n, 0 ≤ w ≤ 109). The next n - 1 lines contain the descriptions of the tree edges. The i-th line contains two integers pi, wi (1 ≤ pi < (i + 1), 0 ≤ wi ≤ 104), that mean that the i-th edge connects vertex (i + 1) and pi and has weight wi.

Consider the tree vertices indexed from 1 to n in some way.

Output

Print a single integer — the number of close pairs.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

4 4 6
1 3
1 4
1 3


Output

4


Input

6 2 17
1 3
2 5
2 13
1 6
5 9


Output

9

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int n, l, w, x, val, sz[100005], vis[100005], fe[100005 + 1005];
long long int ans;
vector<pair<int, long long int> > v[100005], kullan;
int calc_sub(int node, int ata) {
  sz[node] = 0;
  for (int i = 0; i < (int)v[node].size(); i++) {
    int go = v[node][i].first;
    if (go == ata || vis[go] == 1) continue;
    sz[node] += calc_sub(go, node);
  }
  return ++sz[node];
}
int f_cen(int node, int ata, int siz) {
  for (int i = 0; i < (int)v[node].size(); i++) {
    int go = v[node][i].first;
    if (go != ata && vis[go] == 0 && sz[go] > siz / 2) {
      return f_cen(go, node, siz);
    }
  }
  return node;
}
void dfs(int node, int ata, long long int ww, int ll) {
  kullan.push_back(make_pair(ww, ll));
  for (int i = 0; i < (int)v[node].size(); i++) {
    int go = v[node][i].first;
    if (go == ata || vis[go] == 1) continue;
    dfs(go, node, ww + v[node][i].second, ll + 1);
  }
}
void update(int node, int val) {
  for (node++; node < 100005; node += node & -node) {
    fe[node] += val;
  }
}
int quer(int node) {
  int res = 0;
  for (node++; node > 0; node -= node & -node) {
    res += fe[node];
  }
  return res;
}
long long int calc() {
  long long int ret = 0;
  int j = (int)kullan.size() - 1;
  sort(kullan.begin(), kullan.end());
  for (int i = 0; i < (int)kullan.size(); i++) {
    update(kullan[i].second, 1);
  }
  for (int i = 0; i < (int)kullan.size(); i++) {
    while (j >= i && kullan[i].first + kullan[j].first > w) {
      update(kullan[j].second, -1);
      j--;
    }
    if (i > j) break;
    update(kullan[i].second, -1);
    ret += quer(l - kullan[i].second);
  }
  return ret;
}
void solve(int cur) {
  int cen = f_cen(cur, -1, calc_sub(cur, -1));
  kullan.clear();
  dfs(cen, -1, 0, 0);
  ans += calc();
  for (int i = 0; i < (int)v[cen].size(); i++) {
    int go = v[cen][i].first;
    if (vis[go] == 1) continue;
    kullan.clear();
    dfs(go, cen, v[cen][i].second, 1);
    ans -= calc();
  }
  vis[cen] = 1;
  for (int i = 0; i < (int)v[cen].size(); i++) {
    int go = v[cen][i].first;
    if (vis[go] == 0) solve(go);
  }
}
int main() {
  scanf("%d %d %d", &n, &l, &w);
  for (int i = 2; i <= n; i++) {
    scanf("%d %d", &x, &val);
    v[x].push_back(make_pair(i, val));
    v[i].push_back(make_pair(x, val));
  }
  solve(1);
  printf("%lld\n", ans);
  return 0;
}