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 maxn = 100005;
int n, mL, mW;
int v[maxn];
void upd(int x, int y) {
  for (; x <= mL + 1; x += x & -x) v[x] += y;
}
int cal(int x) {
  int res = 0;
  for (; x; x -= x & -x) res += v[x];
  return res;
}
int point[maxn << 1], nextp[maxn << 1], head[maxn], aval[maxn << 1], ecnt;
void ins(int u, int v, int w) {
  point[++ecnt] = v;
  nextp[ecnt] = head[u];
  aval[ecnt] = w;
  head[u] = ecnt;
}
long long ans;
bool ban[maxn];
int enquiry(int x) {
  static int q[maxn], fa[maxn], sz[maxn], l, r, i, p, np;
  l = r = 0;
  q[r++] = x;
  fa[x] = 0;
  while (l < r) {
    p = q[l++];
    sz[p] = 1;
    for (i = head[p]; i; i = nextp[i]) {
      np = point[i];
      if (np == fa[p] || ban[np]) continue;
      q[r++] = np;
      fa[np] = p;
    }
  }
  int Mn = n, Mx, Id = 0;
  for (l = r - 1; l >= 0; l--) {
    Mx = 0;
    p = q[l];
    for (i = head[p]; i; i = nextp[i]) {
      np = point[i];
      if (np == fa[p] || ban[np]) continue;
      if (Mx < sz[np]) Mx = sz[np];
      sz[p] += sz[np];
    }
    if (Mx < r - sz[p]) Mx = r - sz[p];
    if (Mx < Mn) Mn = Mx, Id = p;
  }
  return Id;
}
int tot;
struct data {
  int val, dis;
  bool operator<(const data& t) const { return val < t.val; }
} d[maxn];
void solve(int huh) {
  int i, j;
  sort(d, d + tot);
  for (j = 0; j < tot; j++) upd(d[j].dis + 1, 1);
  for (i = 0; i < tot; i++) {
    while (j && d[j - 1].val + d[i].val > mW) --j, upd(d[j].dis + 1, -1);
    if (d[i].dis <= mL) ans += cal(mL - d[i].dis + 1) * huh;
  }
  while (j) --j, upd(d[j].dis + 1, -1);
}
void dfs(int x, int f, int val, int dis) {
  int i, to;
  d[tot++] = (data){val, dis};
  for (i = head[x]; i; i = nextp[i]) {
    to = point[i];
    if (to != f && !ban[to]) dfs(to, x, val + aval[i], dis + 1);
  }
}
void divide(int x) {
  x = enquiry(x);
  int i, to;
  for (i = head[x]; i; i = nextp[i]) {
    to = point[i];
    if (!ban[to]) {
      tot = 0;
      dfs(to, x, aval[i], 1);
      solve(-1);
    }
  }
  tot = 0;
  dfs(x, 0, 0, 0);
  solve(1);
  --ans;
  ban[x] = 1;
  for (i = head[x]; i; i = nextp[i]) {
    to = point[i];
    if (!ban[to]) divide(to);
  }
}
int main() {
  int i, u, w;
  scanf("%d%d%d", &n, &mL, &mW);
  for (i = 2; i <= n; i++) {
    scanf("%d%d", &u, &w);
    ins(u, i, w);
    ins(i, u, w);
  }
  divide(1);
  ans >>= 1;
  cout << ans << endl;
  return 0;
}