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 T1>
void deb(T1 e1) {
  cout << e1 << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
int on(int n, int pos) { return n = n | (1 << pos); }
int dx[] = {0, 0, 1, -1};
int dy[] = {-1, 1, 0, 0};
struct node {
  long long int cst, lev;
  node() {}
  node(long long int _cst, long long int _lev) {
    cst = _cst;
    lev = _lev;
  }
  bool operator<(const node &P) const {
    if (cst == P.cst) return lev < P.lev;
    return cst < P.cst;
  }
};
int tree[200000], sz[200000], darr[200000], N, L, C;
vector<int> vc[200000], cost[200000];
long long int tot;
vector<node> ac;
int query(int idx) {
  int sum = 0;
  while (idx > 0) {
    sum += tree[idx];
    idx -= idx & (-idx);
  }
  return sum;
}
void update(int idx, int x, int n) {
  while (idx <= n) {
    tree[idx] += x;
    idx += idx & (-idx);
  }
}
void dfs(int v, int par) {
  sz[v] = 1;
  for (int i = 0; i < vc[v].size(); i++) {
    int w = vc[v][i];
    if (w == par || darr[w]) continue;
    dfs(w, v);
    sz[v] += sz[w];
  }
}
int getdc(int v, int par, int n) {
  for (int i = 0; i < vc[v].size(); i++) {
    int w = vc[v][i];
    if (w == par || darr[w]) continue;
    if (sz[w] > (n / 2)) return getdc(w, v, n);
  }
  return v;
}
void makepath(int v, int par, long long int dist, long long int lev) {
  if (dist > C or lev > L) return;
  ac.push_back(node(dist, lev));
  for (int i = 0; i < vc[v].size(); i++) {
    int w = vc[v][i];
    if (w == par || darr[w]) continue;
    makepath(w, v, dist + cost[v][i], lev + 1);
  }
}
long long int fun() {
  sort(ac.begin(), ac.end());
  int j = 0, i = ac.size() - 1;
  long long int ans = 0;
  for (; i >= 0; i--) {
    for (; j < i && ac[i].cst + ac[j].cst <= C; j++) {
      update(ac[j].lev + 1, 1, N);
    }
    if (j > i) {
      update(ac[j - 1].lev + 1, -1, N);
      j--;
    }
    ans += query(L - ac[i].lev + 1);
  }
  return ans;
}
void decompo(int v, int n) {
  ac.clear();
  dfs(v, v);
  n = sz[v];
  int dc = getdc(v, v, n);
  darr[dc] = 1;
  makepath(dc, dc, 0, 0);
  long long int ret = fun();
  for (int i = 0; i < vc[dc].size(); i++) {
    int w = vc[dc][i];
    if (darr[w]) continue;
    ac.clear();
    makepath(w, dc, cost[dc][i], 1);
    ret -= fun();
  }
  tot += ret;
  for (int i = 0; i < vc[dc].size(); i++) {
    int w = vc[dc][i];
    if (darr[w]) continue;
    decompo(w, n);
  }
}
int main() {
  int i, j, k, l, m, n;
  scanf("%d%d%d", &N, &L, &C);
  for (i = 2; i <= N; i++) {
    scanf("%d%d", &l, &j);
    vc[l].push_back(i);
    vc[i].push_back(l);
    cost[l].push_back(j);
    cost[i].push_back(j);
  }
  decompo(1, N);
  cout << tot << endl;
}