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;
template <class P, class Q>
inline void smin(P &a, Q b) {
  if (b < a) a = b;
}
template <class P, class Q>
inline void smax(P &a, Q b) {
  if (a < b) a = b;
}
const int maxn = 100000 + 100;
int n, OL, OW;
vector<pair<int, int> > adj[maxn];
bool mark[maxn];
int sub_size[maxn];
long long ans;
int fen[maxn];
int get_size(int u, int par = -1) {
  int ret = 1;
  for (pair<int, int> vw : adj[u])
    if (vw.first != par && !mark[vw.first]) ret += get_size(vw.first, u);
  return sub_size[u] = ret;
}
int find_center(int u, int comp_size, int par = -1) {
  int max_sub = comp_size - sub_size[u];
  for (pair<int, int> vw : adj[u])
    if (vw.first != par && !mark[vw.first]) {
      int tmp = find_center(vw.first, comp_size, u);
      if (tmp != -1) return tmp;
      smax(max_sub, sub_size[vw.first]);
    }
  if (max_sub <= comp_size / 2) return u;
  return -1;
}
vector<pair<int, int> > store;
void dfs_gen(int u, int par, int curL = 0, int curW = 0) {
  if (mark[u] || curL > OL || curW > OW) return;
  store.push_back({curW, curL});
  for (pair<int, int> vw : adj[u])
    if (vw.first != par) dfs_gen(vw.first, u, curL + 1, curW + vw.second);
}
inline void add_fen(int pos, int val) {
  for (pos++; pos < maxn; pos += pos & -pos) fen[pos] += val;
}
inline int get_fen(int pos) {
  int ret = 0;
  for (pos = max(pos, 0); pos; pos -= pos & -pos) ret += fen[pos];
  return ret;
}
long long cnt(int u, int par, int L, int W) {
  store.clear();
  dfs_gen(u, par);
  sort((store).begin(), (store).end());
  long long ret = 0;
  int pos = 0;
  for (int i = (int)((int((store).size()))), _x = (int)(0); i-- > _x;) {
    while (pos < (int((store).size())) &&
           store[pos].first + store[i].first <= W)
      add_fen(store[pos].second, 1), pos++;
    ret += get_fen(L - store[i].second + 1);
  }
  while (pos--) add_fen(store[pos].second, -1);
  return ret;
}
void solve(int u) {
  int comp_size = get_size(u);
  u = find_center(u, comp_size);
  ans += cnt(u, -1, OL, OW) - 1;
  for (pair<int, int> vw : adj[u])
    if (!mark[vw.first]) ans -= cnt(vw.first, u, OL - 2, OW - 2 * vw.second);
  mark[u] = true;
  for (pair<int, int> vw : adj[u])
    if (!mark[vw.first]) solve(vw.first);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> OL >> OW;
  for (int u = (int)(1), _n = (int)(n); u < _n; u++) {
    int v, w;
    cin >> v >> w;
    v--;
    adj[u].push_back({v, w});
    adj[v].push_back({u, w});
  }
  solve(0);
  cout << ans / 2 << endl;
  { return 0; }
}