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 max_n = 100 * 100 * 10 + 10;
int n, L, W;
vector<pair<int, int> > c[max_n];
int sz[max_n];
bool used[max_n];
int set_size(int s, int par) {
  sz[s] = 1;
  for (auto node : c[s])
    if (node.first != par && !used[node.first])
      sz[s] += set_size(node.first, s);
  return sz[s];
}
int find_centroid(int s) {
  set_size(s, -1);
  int t_size = sz[s];
  while (1) {
    bool f = false;
    for (auto node : c[s])
      if (!used[node.first] && sz[node.first] > t_size / 2) {
        sz[s] = t_size - sz[node.first];
        s = node.first;
        f = true;
        break;
      }
    if (!f) break;
  }
  used[s] = true;
  return s;
}
pair<int, int> dist[max_n];
vector<pair<int, int> > seq[max_n], tmp;
int fen[max_n];
void f_add(int x, int val) {
  x++;
  for (; x < max_n; x += (-x) & x) fen[x] += val;
}
int f_get(int x) {
  x++;
  int res = 0;
  for (; x > 0; x -= (-x) & x) res += fen[x];
  return res;
}
long long ans;
void make_list(int s, int par, int idx, int val, int h) {
  seq[idx].push_back(make_pair(val, h));
  for (auto node : c[s])
    if (node.first != par && !used[node.first])
      make_list(node.first, s, idx, val + node.second, h + 1);
}
void two_pointer(const vector<pair<int, int> >& seq, int z) {
  int l = (int)seq.size() - 1;
  for (int i = 0; i < (int)seq.size(); i++) {
    while (l != -1 && seq[l].first + seq[i].first <= W) {
      f_add(seq[l].second, 1);
      l--;
    }
    ans += 1LL * z * f_get(L - seq[i].second);
  }
  for (int i = l + 1; i < (int)seq.size(); i++) f_add(seq[i].second, -1);
}
void solve(int s) {
  s = find_centroid(s);
  seq[s].push_back(make_pair(0, 0));
  two_pointer(seq[s], -1);
  for (auto node : c[s])
    if (!used[node.first]) {
      make_list(node.first, s, node.first, node.second, 1);
      sort(seq[node.first].begin(), seq[node.first].end(),
           greater<pair<int, int> >());
      two_pointer(seq[node.first], -1);
      if (seq[node.first].size() > seq[s].size()) seq[s].swap(seq[node.first]);
      seq[s].swap(tmp);
      seq[s].clear();
      merge(tmp.begin(), tmp.end(), seq[node.first].begin(),
            seq[node.first].end(), back_inserter(seq[s]),
            greater<pair<int, int> >());
    }
  two_pointer(seq[s], 1);
  seq[s].clear();
  for (auto node : c[s]) seq[node.first].clear();
  for (auto node : c[s])
    if (!used[node.first]) solve(node.first);
}
int main() {
  cin >> n >> L >> W;
  for (int i = 1; i < n; i++) {
    int p, w;
    cin >> p >> w;
    p--;
    c[p].push_back(make_pair(i, w));
    c[i].push_back(make_pair(p, w));
  }
  solve(0);
  cout << ans / 2 << endl;
}