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;
int length, weight;
namespace BIT {
int C[100005];
int lowbit(int t) { return t & (-t); }
void update(int x, int v) {
  for (; x < 100005; x += lowbit(x)) C[x] += v;
}
int query(int x) {
  int re = 0;
  for (; x > 0; x -= lowbit(x)) re += C[x];
  return re;
}
};  // namespace BIT
long long answer;
struct Node {
  int u, d1, d2;
  Node(int u = 0, int d1 = 0, int d2 = 0) : u(u), d1(d1), d2(d2) {}
};
vector<Node> v;
bool cmp(Node a, Node b) { return a.d2 < b.d2; }
int n, edges, root, sn;
int hd[100005], to[100005 << 1], nex[100005 << 1], val[100005 << 1];
int size[100005], mx[100005], vis[100005], rt[100005];
void add(int u, int v, int c) {
  nex[++edges] = hd[u], hd[u] = edges, to[edges] = v, val[edges] = c;
}
void getroot(int u, int ff) {
  size[u] = 1, mx[u] = 0;
  for (int i = hd[u]; i; i = nex[i])
    if (to[i] != ff && !vis[to[i]])
      getroot(to[i], u), size[u] += size[to[i]],
          mx[u] = max(mx[u], size[to[i]]);
  mx[u] = max(mx[u], sn - size[u]);
  if (mx[u] < mx[root]) root = u;
}
void getdis(int u, int ff, int d1, int d2) {
  v.push_back(Node(u, d1, d2));
  for (int i = hd[u]; i; i = nex[i])
    if (to[i] != ff && !vis[to[i]]) getdis(to[i], u, d1 + 1, d2 + val[i]);
}
long long calc(int u, int D1, int D2) {
  getdis(u, 0, D1, D2);
  sort(v.begin(), v.end(), cmp);
  long long re = 0;
  int i, j, l = 0, r = (int)v.size() - 1;
  for (i = 1; i < (int)v.size(); ++i) BIT::update(v[i].d1 + 1, 1);
  while (l < r) {
    if (v[l].d2 + v[r].d2 <= weight) {
      re += (long long)BIT::query(length - v[l].d1 + 1);
      ++l, BIT::update(v[l].d1 + 1, -1);
    } else {
      BIT::update(v[r].d1 + 1, -1);
      --r;
    }
  }
  v.clear();
  return re;
}
void solve(int u) {
  vis[u] = 1;
  answer += calc(u, 0, 0);
  for (int i = hd[u]; i; i = nex[i])
    if (!vis[to[i]]) answer -= calc(to[i], 1, val[i]);
  for (int i = hd[u]; i; i = nex[i])
    if (!vis[to[i]]) sn = size[to[i]], root = 0, getroot(to[i], u), solve(root);
}
int main() {
  int i, j;
  scanf("%d%d%d", &n, &length, &weight);
  for (i = 1; i < n; ++i) {
    int a = i + 1, b, c;
    scanf("%d%d", &b, &c), add(a, b, c), add(b, a, c);
  }
  mx[root = 0] = sn = n, getroot(1, 0), solve(root);
  printf("%lld\n", answer);
  return 0;
}