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;
inline int read() {
  int x = 0;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch <= '9' && ch >= '0'; x = x * 10 + ch - 48, ch = getchar())
    ;
  return x;
}
int i, j, k, m, t[100010], allsz, n, x, y, L, W, cnt, rt, last[100010],
    sz[100010], f[100010], dp[100010], dpw[100010];
bool et[100010];
struct edge {
  int to, next, v;
} e[100010 << 1];
inline void add(int u, int w, int v) {
  e[++cnt] = (edge){v, last[u], w}, last[u] = cnt;
  e[++cnt] = (edge){u, last[v], w}, last[v] = cnt;
}
void dfs(int x, int fa) {
  for (int i = last[x], y; i; i = e[i].next)
    if ((y = e[i].to) != fa && !et[y])
      dp[y] = dp[x] + 1, dpw[y] = dpw[x] + e[i].v, dfs(y, x);
}
inline void Mx(int& a, int b) {
  if (b > a) a = b;
}
void find(int x, int fa) {
  sz[x] = 1, f[x] = 0;
  for (int i = last[x], y; i; i = e[i].next)
    if ((y = e[i].to) != fa && !et[y])
      find(y, x), sz[x] += sz[y], Mx(f[x], sz[x]);
  Mx(f[x], allsz - sz[x]);
  if (f[x] < f[rt]) rt = x;
}
void getnodes(int x, int fa, vector<int>& v) {
  v.push_back(x);
  for (int i = last[x], y; i; i = e[i].next)
    if ((y = e[i].to) != fa && !et[y]) getnodes(y, x, v);
}
inline bool cmp(const int& a, const int& b) { return dpw[a] < dpw[b]; }
inline void ins(int x, int v) {
  for (++x; x <= n + 1; t[x] += v, x += x & -x)
    ;
}
inline int ask(int x) {
  int v = 0;
  for (++x; x > 0; v += t[x], x -= x & -x)
    ;
  return v;
}
inline long long work(int x) {
  vector<int> s;
  getnodes(x, 0, s), sort(s.begin(), s.end(), cmp);
  for (int i = 0; i < s.size(); ++i) ins(dp[s[i]], 1);
  long long ans = 0;
  for (int r = s.size() - 1, l = 0; l < s.size(); ++l) {
    while (l <= r && dpw[s[l]] + dpw[s[r]] > W) ins(dp[s[r--]], -1);
    if (r < l) break;
    ins(dp[s[l]], -1), ans += ask(L - dp[s[l]]);
  }
  return ans;
}
long long solve(int x) {
  et[x] = 1, dp[x] = dpw[x] = 0, dfs(x, 0);
  long long ans = work(x);
  for (int i = last[x]; i; i = e[i].next)
    if (!et[e[i].to]) ans -= work(e[i].to);
  for (int i = last[x], y; i; i = e[i].next)
    if (!et[y = e[i].to])
      f[0] = allsz = sz[y], find(y, rt = 0), ans += solve(rt);
  return ans;
}
int main() {
  for (n = read(), L = read(), W = read(), i = 1; i < n; ++i)
    add(i + 1, read(), read());
  f[0] = allsz = n, find(1, rt = 0), printf("%I64d\n", solve(rt));
}