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;
long long read() {
  long long x = 0, f = 1;
  char ch;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long n, m, W, L;
long long ans;
long long head[2000010], pos;
struct edge {
  long long to, next, c;
} e[2000010 << 1];
void add(long long a, long long b, long long c) {
  pos++;
  e[pos].to = b, e[pos].c = c, e[pos].next = head[a], head[a] = pos;
}
void insert(long long a, long long b, long long c) {
  add(a, b, c);
  add(b, a, c);
}
long long f[2000010], size[2000010], sum, rt;
bool vis[2000010];
void find_root(long long u, long long fa) {
  size[u] = 1, f[u] = 0;
  for (long long i = head[u]; i; i = e[i].next) {
    long long v = e[i].to;
    if (v == fa || vis[v]) continue;
    find_root(v, u);
    size[u] += size[v];
    f[u] = max(f[u], size[v]);
  }
  f[u] = max(f[u], sum - size[u]);
  if (f[u] < f[rt]) rt = u;
}
long long C[2000010], tot, st;
void add(long long x, long long val) {
  if (x <= 0) return;
  while (x <= n) {
    C[x] += val;
    x += x & (-x);
  }
}
long long ask(long long x) {
  long long ret = 0;
  if (x < 0) return 0;
  while (x) {
    ret += C[x];
    x -= x & (-x);
  }
  return ret;
}
struct node {
  long long w, l;
} d[2000010], p[2000010];
bool operator<(node a, node b) { return a.w < b.w; }
long long sz;
void get_dep(long long u, long long fa) {
  sz++;
  for (long long i = head[u]; i; i = e[i].next) {
    long long v = e[i].to;
    if (v == fa || vis[v]) continue;
    d[v].l = d[u].l + 1, d[v].w = d[u].w + e[i].c;
    p[++tot] = d[v];
    get_dep(v, u);
  }
}
long long cal(long long u, long long now1, long long now2) {
  tot = 0;
  d[u].w = now1, d[u].l = now2;
  sz = 0;
  get_dep(u, 0);
  long long ret = 0;
  sort(p + 1, p + tot + 1);
  long long l = 1, r = tot;
  for (long long i = l; i <= r; i++) {
    add(p[i].l, 1);
    if (p[i].l + now2 <= L && p[i].w + now1 <= W) ret++;
  }
  while (l < r) {
    if (p[l].w + p[r].w > W)
      add(p[r--].l, -1);
    else {
      add(p[l].l, -1);
      ret += ask(L - p[l].l);
      l++;
    }
  }
  while (l <= r) {
    add(p[l].l, -1);
    l++;
  }
  return ret;
}
void work(long long u) {
  vis[u] = 1;
  ans += cal(u, 0, 0);
  for (long long i = head[u]; i; i = e[i].next) {
    long long v = e[i].to;
    if (vis[v]) continue;
    ans -= cal(v, e[i].c, 1);
    sum = size[v], rt = 0;
    find_root(v, 0);
    work(rt);
  }
}
int main() {
  n = read();
  L = read();
  W = read();
  for (long long i = 1; i < n; i++) {
    long long a = i + 1, b = read(), c = read();
    insert(a, b, c);
  }
  f[0] = 1 << 26, sum = n;
  find_root(1, 0);
  work(rt);
  cout << ans << "\n";
}