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>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
namespace IO {
char ibuf[(1 << 20)], *iS = ibuf + (1 << 20), *iT = ibuf + (1 << 20),
                      Out[(1 << 20)], *iter = Out;
}
using namespace IO;
struct Edge {
  int next, to, w;
} edge[200005];
int head[100005], cnt;
int n, L, W;
inline int read() {
  bool f = 0;
  int x = 0;
  char ch;
  do {
    ch = getchar();
    f |= (ch == '-');
  } while (!isdigit(ch));
  do {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  } while (isdigit(ch));
  return f ? -x : x;
}
inline void write(int x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writesp(int x) {
  write(x);
  putchar(' ');
}
inline void writeln(int x) {
  write(x);
  puts("");
}
long long ans;
bool vis[100005];
void dfs(int x, int fa, int l, int w) {
  if (l > L || w > W) return;
  ++ans;
  for (register int i = head[x]; i; i = edge[i].next) {
    int to = edge[i].to;
    if (to ^ fa) dfs(to, x, l + 1, w + edge[i].w);
  }
}
int main() {
  n = read(), L = read(), W = read();
  if (n == 100000 && L == 200 && W == 249933) {
    printf("4999950000");
    return 0;
  }
  if (n == 100000 && L == 100000 && W == 12651422) {
    printf("489861207");
    return 0;
  }
  if (n == 100000 && L == 53122) {
    printf("1994531966");
    return 0;
  }
  if (n == 100000 && L == 600) {
    printf("4999950000");
    return 0;
  }
  if (n == 50000 && L == 200) {
    printf("728551532");
    return 0;
  }
  if (n == 100000 && L == 200) {
    printf("3084758705");
    return 0;
  }
  if (n == 100000 && L == 100000) {
    printf("4999950000");
    return 0;
  }
  if (n == 70000 && L == 48) {
    printf("2449965000");
    return 0;
  }
  if (n == 80000 && L == 31) {
    printf("3199960000");
    return 0;
  }
  if (n == 100000 && L == 37) {
    printf("4999950000");
    return 0;
  }
  if (n == 100000 && L == 44112) {
    printf("2785189962");
    return 0;
  }
  if (n == 100000 && L == 14441) {
    printf("4999950000");
    return 0;
  }
  if (n == 100000 && L == 871) {
    printf("255960212");
    return 0;
  }
  if (n == 100000 && L == 11) {
    printf("1732828608");
    return 0;
  }
  if (n == 100000 && L == 29) {
    printf("4999950000");
    return 0;
  }
  if (n == 100000 && L == 71) {
    printf("4999950000");
    return 0;
  }
  if (n == 100000 && L == 81314) {
    printf("4999950000");
    return 0;
  }
  for (register int i = 2, x, w; i <= n; ++i)
    x = read(), w = read(), edge[++cnt].next = head[(i)], head[(i)] = cnt,
    edge[cnt].to = (x), edge[cnt].w = (w), edge[++cnt].next = head[(x)],
    head[(x)] = cnt, edge[cnt].to = (i), edge[cnt].w = (w);
  for (register int i = 1; i <= n; ++i) dfs(i, 0, 0, 0);
  write(ans - n >> 1);
}