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;
template <typename tp>
tp read() {
  char c = getchar();
  tp x = 0;
  bool sgn = 0;
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') sgn = 1, c = getchar();
  while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0', c = getchar();
  return sgn ? -x : x;
}
template <typename tp>
void write(tp x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x >= 10) write(x / 10);
    putchar(x % 10 + '0');
  }
}
struct edge {
  long long to, next, w;
} e[100005 << 1];
long long head[100005], cnte;
void add(long long u, long long v, long long w) {
  e[++cnte].to = v;
  e[cnte].next = head[u];
  e[cnte].w = w;
  head[u] = cnte;
}
long long n, l, k, ANS;
bool vis[100005];
namespace GG {
long long sz[100005], G, szG;
long long inittrsz(long long u, long long last) {
  long long trsz = 1;
  for (long long i = head[u]; i; i = e[i].next) {
    long long v = e[i].to;
    if (v == last || vis[v]) continue;
    trsz += inittrsz(v, u);
  }
  return trsz;
}
void getG1(long long u, long long last, long long trsz) {
  long long ret = 0;
  sz[u] = 1;
  for (long long i = head[u]; i; i = e[i].next) {
    long long v = e[i].to;
    if (v == last || vis[v]) continue;
    getG1(v, u, trsz);
    ret = max(ret, sz[v]);
    sz[u] += sz[v];
  }
  ret = max(ret, trsz - sz[u]);
  if (ret < szG) {
    szG = ret;
    G = u;
  }
}
long long getG(long long u) {
  long long trsz = inittrsz(u, 0);
  szG = 1050000000;
  getG1(u, 0, trsz);
  return G;
}
}  // namespace GG
namespace BIT {
long long tr[100005], cnt;
void add(long long pos, long long k) {
  pos++;
  while (pos <= cnt) {
    tr[pos] += k;
    pos += pos & -pos;
  }
}
long long query(long long pos) {
  if (pos < 0) return 0;
  if (pos < cnt)
    pos++;
  else
    pos = cnt;
  long long ret = 0;
  while (pos) {
    ret += tr[pos];
    pos -= pos & -pos;
  }
  return ret;
}
}  // namespace BIT
namespace SOLVE {
long long cnt;
struct T {
  long long dis, dep;
  bool operator<(const T& x) const { return dis < x.dis; }
} t[100005];
void work(long long u, long long last, long long now_w, long long now_dep) {
  t[++cnt].dis = now_w;
  t[cnt].dep = now_dep;
  for (long long i = head[u]; i; i = e[i].next) {
    long long v = e[i].to;
    if (v == last || vis[v]) continue;
    work(v, u, now_w + e[i].w, now_dep + 1);
  }
}
long long solve(long long u, long long kk, long long ll) {
  cnt = 0;
  work(u, 0, 0, 0);
  sort(t + 1, t + cnt + 1);
  BIT::cnt = 0;
  for (long long i = 1; i <= cnt; i++) BIT::cnt = max(BIT::cnt, t[i].dep + 1);
  for (long long i = 1; i <= cnt; i++) BIT::add(t[i].dep, 1);
  long long ans = 0, I, J;
  for (I = 1, J = cnt; I < J;) {
    if (t[I].dis + t[J].dis <= kk) {
      BIT::add(t[I].dep, -1);
      ans += BIT::query(ll - t[I].dep);
      I++;
    } else {
      BIT::add(t[J].dep, -1);
      J--;
    }
  }
  BIT::add(t[J].dep, -1);
  return ans;
}
}  // namespace SOLVE
void dfs(long long g) {
  long long ans = SOLVE::solve(g, k, l);
  vis[g] = 1;
  for (long long i = head[g]; i; i = e[i].next) {
    long long v = e[i].to;
    if (vis[v]) continue;
    ans -= SOLVE::solve(v, k - (e[i].w << 1), l - 2);
  }
  ANS += ans;
  for (long long i = head[g]; i; i = e[i].next) {
    long long v = e[i].to;
    if (vis[v]) continue;
    long long gg = GG::getG(v);
    dfs(gg);
  }
}
signed main() {
  n = read<long long>(), l = read<long long>(), k = read<long long>();
  for (long long i = 1; i <= n; i++) vis[i] = head[i] = 0;
  cnte = 0;
  for (long long i = 2; i <= n; i++) {
    long long u = read<long long>(), w = read<long long>();
    add(u, i, w);
    add(i, u, w);
  }
  ANS = 0;
  long long g = GG::getG(1);
  dfs(g);
  write(ANS);
  return 0;
}