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;
vector<int> adj[300007];
vector<int> cst[300007];
int stree[300007];
int removed[300007];
int tot;
void dfs(int u, int papa) {
  tot++;
  stree[u] = 1;
  for (auto v : adj[u]) {
    if (v == papa || removed[v]) continue;
    dfs(v, u);
    stree[u] += stree[v];
  }
}
int find_center(int u, int papa) {
  for (auto v : adj[u]) {
    if (v == papa || removed[v]) continue;
    if (stree[v] > tot / 2) return find_center(v, u);
  }
  return u;
}
vector<pair<int, int> > ww;
long long ret;
int tree[300007];
void update(int idx, int v) {
  idx++;
  for (; idx < 300007; idx += (idx & -idx)) tree[idx] += v;
}
int read(int idx) {
  int ret = 0;
  idx++;
  for (; idx > 0; idx -= (idx & -idx)) ret += tree[idx];
  return ret;
}
long long W, L;
long long find_pair() {
  sort(ww.begin(), ww.end());
  int j = 0;
  long long ret = 0;
  for (int i = ((int)ww.size()) - 1; i >= 0; i--) {
    while (j < ww.size() && ww[i].first + ww[j].first <= W) {
      update(ww[j].second, 1);
      j++;
    }
    int need = L - ww[i].second;
    if (need >= 0) ret += read(need);
  }
  for (int i = 0; i <= j - 1; i++) update(ww[i].second, -1);
  return ret;
}
void make_array(int u, int papa, int w, int l) {
  if (w > W) return;
  ww.push_back(make_pair(w, l));
  for (int i = 0; i < (int)adj[u].size(); i++) {
    int v = adj[u][i];
    int c = cst[u][i];
    if (v == papa || removed[v]) continue;
    make_array(v, u, w + c, l + 1);
  }
}
long long calculate(int u) {
  long long ret = 0;
  ww.clear();
  make_array(u, -1, 0, 0);
  ret += find_pair();
  for (int i = 0; i < (int)adj[u].size(); i++) {
    int v = adj[u][i];
    int c = cst[u][i];
    if (removed[v]) continue;
    ww.clear();
    make_array(v, u, c, 1);
    ret -= find_pair();
  }
  return (ret / 2);
}
long long decompose(int u) {
  tot = 0;
  dfs(u, -1);
  int center = find_center(u, -1);
  removed[center] = 1;
  long long ret = calculate(center);
  for (auto v : adj[center]) {
    if (removed[v]) continue;
    ret += decompose(v);
  }
  return ret;
}
int main() {
  int n;
  scanf("%d%d%d", &(n), &(L), &(W));
  for (int i = 1; i <= n - 1; i++) {
    int p, w;
    scanf("%d%d", &(p), &(w));
    int x = i + 1;
    int y = p;
    adj[x].push_back(y);
    adj[y].push_back(x);
    cst[x].push_back(w);
    cst[y].push_back(w);
  }
  long long ret = decompose(1);
  cerr << "ret"
       << ": " << ret << endl;
  ;
  printf("%lld\n", ret);
  return 0;
}