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 N = 100005;
const int inf = 1000000009;
int rd() {
  char c = getchar();
  int t = 0, f = 1;
  while (!isdigit(c)) f = (c == '-') ? -1 : 1, c = getchar();
  while (isdigit(c)) t = t * 10 + c - 48, c = getchar();
  return t * f;
}
void wt(int x) {
  if (x < 0) {
    putchar('-');
    wt(-x);
    return;
  }
  if (x > 9) wt(x / 10);
  putchar(x % 10 + 48);
  return;
}
pair<int, int> stk[N];
long long Ans;
int head[N], cnt, top, vis[N], sz[N], f[N], sum, l, w, x, rt, n;
struct Fenwick_Tree {
  int c0, A[N];
  void add(int x, int y) {
    if (x == 0)
      c0 += y;
    else {
      for (; x <= l; x += x & -x) A[x] += y;
    }
  }
  int ask(int x) {
    int t = c0;
    for (; x; x -= x & -x) t += A[x];
    return t;
  }
} BIT;
struct Edge {
  int to, nxt, val;
} E[N << 1];
void Link(int u, int v, int w) {
  E[++cnt] = (Edge){v, head[u], w};
  head[u] = cnt;
  E[++cnt] = (Edge){u, head[v], w};
  head[v] = cnt;
}
void getrt(int x, int fa) {
  f[x] = 0;
  sz[x] = 1;
  for (int y, i = head[x]; i; i = E[i].nxt)
    if ((y = E[i].to) != fa && !vis[y]) {
      getrt(y, x);
      sz[x] += sz[y];
      if (sz[y] > f[x]) f[x] = sz[y];
    }
  f[x] = max(f[x], sum - sz[x]);
  if (f[x] < f[rt]) rt = x;
  return;
}
void dfs(int x, int fa, int dep, long long sum) {
  if (sum > w || dep > l) return;
  stk[++top] = make_pair(sum, dep);
  for (int y, i = head[x]; i; i = E[i].nxt)
    if ((y = E[i].to) != fa && !vis[y]) dfs(y, x, dep + 1, sum + E[i].val);
}
long long cal() {
  long long Ret = 0;
  int h = 0;
  sort(stk + 1, stk + top + 1);
  for (int i = ((int)top); i >= ((int)1); i--) {
    while (h > i - 1) BIT.add(stk[h].second, -1), h--;
    while (stk[i].first + stk[h + 1].first <= w && h < i - 1)
      h++, BIT.add(stk[h].second, 1);
    Ret += BIT.ask(l - stk[i].second);
  }
  h = 0;
  for (int i = ((int)top); i >= ((int)1); i--) {
    while (h > i - 1) BIT.add(stk[h].second, 1), h--;
    while (stk[top].first + stk[h + 1].first <= w && h < i - 1)
      h++, BIT.add(stk[h].second, -1);
  }
  top = 0;
  return Ret;
}
void solve(int x) {
  dfs(x, -1, 0, 0);
  Ans += cal();
  vis[x] = 1;
  for (int y, i = head[x]; i; i = E[i].nxt)
    if (!vis[y = E[i].to]) {
      dfs(E[i].to, x, 1, E[i].val);
      Ans -= cal();
    }
  for (int y, i = head[x]; i; i = E[i].nxt)
    if (!vis[y = E[i].to]) {
      sum = sz[y];
      rt = 0;
      getrt(y, x);
      solve(rt);
    }
}
int main() {
  sum = n = rd(), l = rd(), w = rd();
  for (int i = ((int)2); i <= ((int)n); i++) x = rd(), Link(i, x, rd());
  f[0] = inf;
  getrt(1, 0);
  solve(rt);
  printf("%I64d\n", Ans);
  return 0;
}