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 = 1e5 + 5;
bool v[maxn];
int sz[maxn], mxson[maxn], rt, S, edge[maxn << 1], ver[maxn << 1], tot,
    head[maxn], next1[maxn << 1], n, l, w, cnt;
int mxL, cnttmp;
pair<long long, int> tmp[maxn];
long long ans = 0;
void add(int x, int y, int z) {
  ver[++tot] = y, next1[tot] = head[x], edge[tot] = z, head[x] = tot;
}
struct BIT {
  int c[maxn];
  void add(int x, int val) {
    x++;
    for (int i = x; i <= n + 1; i += (i & (-i))) c[i] += val;
  }
  int ask(int x) {
    x++;
    int ans = 0;
    for (int i = x; i; i -= (i & (-i))) ans += c[i];
    return ans;
  }
} bit;
void getRoot(int x, int f) {
  sz[x] = 1;
  mxson[x] = 0;
  for (int i = head[x]; i; i = next1[i]) {
    int y = ver[i];
    if (v[y] || y == f) continue;
    getRoot(y, x);
    sz[x] += sz[y];
    mxson[x] = max(mxson[x], sz[y]);
  }
  mxson[x] = max(mxson[x], S - sz[x]);
  if (mxson[x] < mxson[rt]) rt = x;
}
void init(int x) {
  mxson[rt = 0] = maxn;
  S = sz[x];
  getRoot(x, 0);
}
void getQue(int x, int f, long long val, int d) {
  tmp[++cnttmp] = {val, d};
  for (int i = head[x]; i; i = next1[i]) {
    int y = ver[i];
    if (v[y] || y == f) continue;
    getQue(y, x, val + edge[i], d + 1);
  }
}
long long cal(int x, long long val, int d) {
  long long sum = 0;
  cnttmp = 0;
  getQue(x, 0, val, d);
  sort(tmp + 1, tmp + 1 + cnttmp);
  int h = 1, t = cnttmp;
  while (h < t && tmp[h].first + tmp[t].first > w) {
    t--;
  }
  if (h < t) {
    for (int i = h + 1; i <= t; ++i) bit.add(tmp[i].second, 1);
    while (h < t) {
      if (tmp[h].first + tmp[t].first <= w) {
        if (l - tmp[h].second >= 0) sum += bit.ask(l - tmp[h].second);
        h++;
        bit.add(tmp[h].second, -1);
      } else {
        bit.add(tmp[t].second, -1);
        t--;
      }
    }
  }
  return sum;
}
void dfz(int x) {
  v[x] = 1;
  ans += cal(x, 0, 0);
  for (int i = head[x]; i; i = next1[i]) {
    int y = ver[i];
    if (v[y]) continue;
    ans -= cal(y, edge[i], 1);
    init(y);
    dfz(rt);
  }
}
int main() {
  scanf("%d%d%d", &n, &l, &w);
  int a, b;
  for (int i = 2; i <= n; ++i) {
    scanf("%d%d", &a, &b);
    add(i, a, b);
    add(a, i, b);
  }
  S = n;
  mxson[rt = 0] = maxn;
  getRoot(1, 0);
  dfz(rt);
  cout << ans << "\n";
  return 0;
}