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;
struct fenwick {
  long long n, fen[100005];
  void resize(int _n) {
    n = _n + 1;
    memset(fen, 0, sizeof fen);
  }
  int query(int ind) {
    ind++;
    int ans = 0;
    while (ind >= 1) {
      ans += fen[ind];
      ind -= ind & -ind;
    }
    return ans;
  }
  void update(int ind, int val) {
    ind++;
    while (ind <= n) {
      fen[ind] += val;
      ind += ind & -ind;
    }
  }
  int query(int l, int r) { return query(r) - query(l - 1); }
};
const int maxn = 100001;
int n, l, w, x, y, sz[maxn];
long long res;
bool blocked[maxn];
vector<pair<int, int> > c, v[maxn];
fenwick tree;
void dfs(int node, int pnode, int curw, int curl) {
  c.push_back(make_pair(curw, curl));
  for (auto &i : v[node])
    if (i.first != pnode && !blocked[i.first])
      dfs(i.first, node, curw + i.second, curl + 1);
}
long long solve(int node, int curw, int curl) {
  long long ret = 0;
  c.clear();
  dfs(node, 0, curw, curl);
  sort(c.begin(), c.end());
  for (auto &i : c) tree.update(i.second, 1);
  for (int i = 0, j = c.size() - 1; i < c.size(); i++) {
    while (i <= j && c[i].first + c[j].first > w)
      tree.update(c[j--].second, -1);
    if (j < i) break;
    tree.update(c[i].second, -1);
    ret += tree.query(l - c[i].second);
  }
  return ret;
}
int dfsz(int node, int pnode) {
  sz[node] = 1;
  for (auto &i : v[node])
    if (i.first != pnode && !blocked[i.first]) sz[node] += dfsz(i.first, node);
  return sz[node];
}
int find(int node, int pnode, int n) {
  for (auto &i : v[node])
    if (i.first != pnode && !blocked[i.first] && 2 * sz[i.first] > n)
      return find(i.first, node, n);
  return node;
}
void decompose(int node) {
  int centroid = find(node, 0, dfsz(node, 0));
  blocked[centroid] = 1;
  res += solve(centroid, 0, 0);
  for (auto &i : v[centroid])
    if (!blocked[i.first])
      res -= solve(i.first, i.second, 1), decompose(i.first);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> l >> w;
  tree.resize(n + 1);
  for (int i = 2; i <= n && cin >> x >> y; i++) {
    v[i].push_back(make_pair(x, y));
    v[x].push_back(make_pair(i, y));
  }
  decompose(1);
  cout << res << endl;
  return 0;
}