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>
const int MAXN = 1e5;
int n, L, WW, edge, allSize, root, tot;
int fst[MAXN | 1], size[MAXN | 1], f[MAXN | 1], D[MAXN | 1], bit[MAXN * 2 | 1];
long long ans;
long long W[MAXN | 1];
bool vis[MAXN | 1];
struct Edge {
  int to, w, nxt;
  Edge(int _to = 0, int _w = 0, int _nxt = 0) : to(_to), w(_w), nxt(_nxt) {}
} e[MAXN << 1];
struct Dot {
  int a, b;
  Dot(int _a = 0, int _b = 0) : a(_a), b(_b) {}
  friend bool operator<(const Dot &lhs, const Dot &rhs) {
    return lhs.a < rhs.a;
  }
} dot[MAXN | 1];
inline int read() {
  register int x = 0, v = 1;
  register char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') v = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * v;
}
inline void add_edge(int a, int b, int c) {
  e[++edge] = Edge(b, c, fst[a]);
  fst[a] = edge;
}
void modify(int x, int y) {
  for (int i = x; i <= n * 2; i += i & -i) bit[i] += y;
}
int query(int x) {
  int res = 0;
  for (int i = x; i > 0; i -= i & -i) res += bit[i];
  return res;
}
void getRoot(int x, int fa) {
  size[x] = 1;
  f[x] = 0;
  for (int k = fst[x]; k; k = e[k].nxt) {
    int to = e[k].to;
    if (to == fa || vis[to]) continue;
    getRoot(to, x);
    size[x] += size[to];
    f[x] = std::max(f[x], size[to]);
  }
  f[x] = std::max(f[x], allSize - size[x]);
  if (f[x] < f[root]) root = x;
}
void dfs(int x, int fa) {
  dot[++tot] = Dot(W[x], D[x]);
  for (int k = fst[x]; k; k = e[k].nxt) {
    int to = e[k].to, w = e[k].w;
    if (to == fa || vis[to]) continue;
    D[to] = D[x] + 1;
    W[to] = W[x] + w;
    dfs(to, x);
  }
}
void getAns(int x, int initD, int initW, int val) {
  long long res = 0;
  D[x] = initD;
  W[x] = initW;
  tot = 0;
  dfs(x, 0);
  std::sort(dot + 1, dot + 1 + tot);
  int j = 1;
  for (int i = tot; i > 1; --i) {
    if (j > i) {
      --j;
      modify(L - dot[j].b + n * 1, -1);
    } else {
      while (j < i && dot[j].a + dot[i].a <= WW) {
        modify(L - dot[j].b + n * 1, 1);
        ++j;
      }
    }
    res += j - 1 - query(dot[i].b - 1 + n * 1);
  }
  for (int i = 1; i < j; ++i) modify(L - dot[i].b + n * 1, -1);
  ans += val * res;
}
void solve(int x) {
  vis[x] = 1;
  getAns(x, 0, 0, 1);
  int lastSize = allSize;
  for (int k = fst[x]; k; k = e[k].nxt) {
    int to = e[k].to, w = e[k].w;
    if (vis[to]) continue;
    getAns(to, 1, w, -1);
    root = 0;
    allSize = size[to] < size[x] ? size[to] : lastSize - size[x];
    getRoot(to, x);
    solve(root);
  }
}
int main() {
  n = read();
  L = read();
  WW = read();
  for (int i = 2; i <= n; ++i) {
    int v = read(), w = read();
    add_edge(i, v, w);
    add_edge(v, i, w);
  }
  f[0] = allSize = n;
  solve(1);
  printf("%lld\n", ans);
  return 0;
}