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;
struct Edge {
  int next, to, dis;
  Edge(int a = 0, int b = 0, int c = 0) : next(a), to(b), dis(c) {}
} e[maxn << 1];
int head[maxn], tot;
void Add(int u, int v, int w) {
  e[++tot] = Edge(head[u], v, w);
  head[u] = tot;
}
long long ans, op;
int N, L, W, size[maxn];
int F, Size, root, vis[maxn];
struct Node {
  int l, d;
  Node(int l = 0, int d = 0) : l(l), d(d) {}
};
Node q[maxn];
int c[maxn], cnt;
void insert(int p, int va) {
  ++p;
  for (; p - 1 <= N; p += p & -p) c[p] += va;
}
void clear(int p) {
  ++p;
  for (; p - 1 <= N; p += p & -p) c[p] = 0;
}
int query(int p) {
  ++p;
  int ans = 0;
  for (; p; p -= p & -p) ans += c[p];
  return ans;
}
void getdep(int x, int fa, int dep, int dis) {
  if (dep > L || dis > W) return;
  q[++cnt] = Node(dep, dis);
  for (int i = head[x]; i; i = e[i].next) {
    int to = e[i].to;
    if (vis[to] || to == fa) continue;
    getdep(to, x, dep + 1, dis + e[i].dis);
  }
}
bool cmp(const Node& x, const Node& y) { return x.d < y.d; }
void calc(int x, int son, int bas) {
  cnt = 0;
  getdep(x, -1, son, bas);
  sort(q + 1, q + cnt + 1, cmp);
  for (int i = 1; i <= cnt; ++i) insert(q[i].l, 1);
  int l = 1, r = cnt;
  while (l < r) {
    insert(q[l].l, -1);
    while (l < r && q[l].d + q[r].d > W) insert(q[r].l, -1), --r;
    ans += op * query(L - q[l].l);
    ++l;
  }
  for (int i = 1; i <= cnt; ++i) clear(q[i].l);
}
int getroot(int x, int fa) {
  int f = 0;
  size[x] = 1;
  for (int i = head[x]; i; i = e[i].next) {
    int to = e[i].to;
    if (vis[to] || to == fa) continue;
    size[x] += getroot(to, x);
    f = max(f, size[to]);
  }
  f = max(f, Size - size[x]);
  if (f <= F) F = f, root = x;
  return size[x];
}
void solve(int x) {
  vis[x] = 1;
  op = 1, calc(x, 0, 0);
  for (int i = head[x]; i; i = e[i].next) {
    int to = e[i].to;
    if (vis[to]) continue;
    op = -1, calc(to, 1, e[i].dis);
    F = Size = size[to];
    getroot(to, x);
    solve(root);
  }
}
int main() {
  scanf("%d%d%d", &N, &L, &W);
  for (int i = 2, a, b; i <= N; ++i) {
    scanf("%d%d", &a, &b);
    Add(a, i, b);
    Add(i, a, b);
  }
  F = Size = N;
  getroot(1, -1);
  solve(root);
  printf("%I64d\n", ans);
  getchar(), getchar();
  return 0;
}