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;
const int IT_MAX = 1 << 18;
const int INF = -1;
int bit[IT_MAX + 10];
void update(int p, int dv) {
  p++;
  for (; p <= IT_MAX; p += p & (-p)) bit[p] += dv;
}
int query(int p) {
  p++;
  int rv = 0;
  for (; p; p -= p & (-p)) rv += bit[p];
  return rv;
}
vector<pair<int, int> > mat[100010], myPaChi, chi;
int lev[100010], pa, cen, sub[100010], tr_sz, dis[100010], wei[100010];
pair<int, int> paInfo[100010];
int W, L;
long long prin;
long long add_pair() {
  long long ret = 0;
  sort(chi.begin(), chi.end());
  reverse(chi.begin(), chi.end());
  int n = chi.size(), i = 0, j = 0;
  for (i = 0, j = n - 1; i < n; i++) {
    for (; j >= 0 && chi[i].first + chi[j].first <= W; j--)
      update(chi[j].second, 1);
    int v = L - chi[i].second;
    if (v >= 0) ret += query(v);
  }
  for (int i = 0; i < n; i++)
    if (chi[i].first + chi[i].first <= W && chi[i].second + chi[i].second <= L)
      ret--;
  for (i = n - 1; i > j; i--) update(chi[i].second, -1);
  chi.clear();
  return ret;
}
void col_info(int p, int baap) {
  if (cen) {
    if (paInfo[p] != make_pair(0, 0)) myPaChi.push_back(paInfo[p]);
    chi.push_back({wei[p], dis[p]});
    paInfo[p] = {wei[p], dis[p]};
  }
  sub[p] = 1;
  for (auto x : mat[p]) {
    if (lev[pa] < lev[x.first]) pa = x.first;
    if (x.first == baap || lev[x.first]) continue;
    dis[x.first] = dis[p] + 1;
    wei[x.first] = wei[p] + x.second;
    col_info(x.first, p);
    sub[p] += sub[x.first];
  }
  if (cen && p == cen) {
    prin += add_pair();
    for (auto x : myPaChi) chi.push_back(x);
    myPaChi.clear();
    prin -= add_pair();
  }
}
int centroid(int p, int baap) {
  if ((sub[p] << 1) <= tr_sz) return baap;
  for (auto x : mat[p])
    if ((sub[x.first] << 1) > tr_sz && !lev[x.first] && x.first != baap)
      return centroid(x.first, p);
  return p;
}
int main() {
  ios::sync_with_stdio(false);
  int n, u, v, c, k;
  cin >> n >> L >> W;
  for (int i = 2; i <= n; i++) {
    u = i;
    cin >> v >> c;
    mat[u].push_back(make_pair(v, c));
    mat[v].push_back(make_pair(u, c));
  }
  for (int l = 1; l <= 18; l++)
    for (int i = 1; i <= n; i++) {
      if (lev[i]) continue;
      pa = 0;
      col_info(i, i);
      tr_sz = sub[i];
      cen = centroid(i, i);
      wei[cen] = dis[cen] = 0;
      col_info(cen, cen);
      lev[cen] = lev[pa] + 1;
      cen = 0;
    }
  cout << ((long long)prin >> 1) << endl;
  return 0;
}