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;
void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(), "w", stdout); }
void setIO(string name) {
  freopen((name + ".in").c_str(), "r", stdin);
  freopen((name + ".out").c_str(), "w", stdout);
}
inline long long read() {
  register long long a = 0, f = 1;
  register char c;
  while ((c = getchar()) < '0')
    if (c == '-') f = -1;
  while (c >= '0') a = a * 10 + (c ^ 48), c = getchar();
  return a * f;
}
inline void write(long long s) {
  if (s < 0) s = -s, putchar('-');
  if (s > 9)
    write(s / 10), putchar(s % 10 + '0');
  else
    putchar(s + '0');
}
inline void Write(long long s) {
  write(s);
  printf(" ");
}
inline void writeln(long long s) {
  write(s);
  puts("");
}
inline char get() {
  char re = getchar();
  while (re == '\r' || re == '\n') re = getchar();
  return re;
}
inline string Get() {
  string s = "";
  char re;
  while (isalpha(re = getchar())) s += re;
  return s;
}
long long Mod(long long a, long long p = (long long)(1e9 + 7)) {
  return a < p ? a : a % p;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long chkmax(long long a, long long b) { return a > b ? a : b; }
long long chkmin(long long a, long long b) { return a < b ? a : b; }
long long qpow(long long base, long long times, long long p = 0) {
  long long ans = 1;
  if (p) base %= p;
  while (times) {
    if (times & 1) {
      ans = ans * base;
      if (p) ans %= p;
    }
    times >>= 1;
    base = base * base;
    if (p) base %= p;
  }
  return ans;
}
long long MaxVal(long long a, long long b, long long *val) {
  long long re = 0;
  for (long long i = a; i <= b; i++) re = chkmax(re, val[i]);
  return re;
}
long long MinVal(long long a, long long b, long long *val) {
  long long re = 1e9;
  for (long long i = a; i <= b; i++) re = chkmin(re, val[i]);
  return re;
}
const long long MAXN = 2e5 + 5;
const long long MAXM = 2e5 + 5;
const long long MAXK = 2e5 + 5;
const long long mod = 1e9 + 7;
long long dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
long long n, m, t, pos[MAXN], k, a, b, c, l, w;
namespace AdjEdge {
long long head[MAXN], tot;
struct Edge {
  long long u, v, d, nxt;
} edge[MAXM << 1];
inline void add(long long u, long long v, long long d = 0) {
  edge[++tot].u = u;
  edge[tot].v = v;
  edge[tot].d = d;
  edge[tot].nxt = head[u];
  head[u] = tot;
}
}  // namespace AdjEdge
using namespace AdjEdge;
namespace BIT {
long long bit[MAXN];
inline void update(long long u, long long val) {
  for (long long i = u; i < MAXN; i += (i & -i)) bit[i] += val;
}
inline long long query(long long u) {
  long long re = 0;
  for (long long i = u; i; i -= (i & -i)) re += bit[i];
  return re;
}
}  // namespace BIT
using namespace BIT;
namespace Centroid_Decomposition {
long long rt = 0, all[MAXK], dp[MAXN], son[MAXN], sz[MAXN], cnt, Ans[MAXN], sum,
          Q[MAXN], dep[MAXN];
long long ans, dis[MAXN];
bool vis[MAXN];
pair<long long, long long> judge[MAXK];
inline void getroot(long long u = 1, long long fa = -1) {
  dp[u] = 0, sz[u] = 1;
  for (long long i = head[u]; i; i = edge[i].nxt) {
    long long v = edge[i].v;
    if (vis[v] || v == fa) continue;
    getroot(v, u);
    sz[u] += sz[v];
    dp[u] = chkmax(dp[u], sz[v]);
  }
  dp[u] = chkmax(dp[u], sum - sz[u]);
  if (dp[u] < dp[rt]) rt = u;
}
inline void getdis(long long u, long long fa = -1) {
  judge[++cnt] = make_pair(dis[u], dep[u]);
  for (long long i = head[u]; i; i = edge[i].nxt) {
    long long v = edge[i].v, d = edge[i].d;
    if (vis[v] || v == fa) continue;
    dis[v] = dis[u] + d;
    dep[v] = dep[u] + 1;
    getdis(v, u);
  }
}
inline void calc(long long u, long long dist, long long depth, long long val) {
  dis[u] = dist;
  dep[u] = depth;
  cnt = 0;
  getdis(u);
  sort(judge + 1, judge + 1 + cnt);
  long long L = 1, R = cnt;
  for (long long i = 1; i <= cnt; i++) update(judge[i].second + 1, 1);
  while (L < R) {
    if (judge[L].first + judge[R].first <= w) {
      update(judge[L].second + 1, -1);
      if (l + 1 >= judge[L].second) ans += query(l - judge[L].second + 1) * val;
      L++;
    } else {
      update(judge[R].second + 1, -1);
      R--;
    }
  }
  update(judge[L].second + 1, -1);
}
inline void divide(long long u = rt) {
  vis[u] = true;
  calc(u, 0, 0, 1);
  for (long long i = head[u]; i; i = edge[i].nxt) {
    long long v = edge[i].v, d = edge[i].d;
    if (vis[v]) continue;
    calc(v, d, 1, -1);
    sum = sz[v];
    dp[rt = 0] = n;
    getroot(v, u);
    divide(rt);
  }
}
}  // namespace Centroid_Decomposition
using namespace Centroid_Decomposition;
signed main() {
  n = read();
  l = read();
  w = read();
  for (long long i = 2; i <= n; i++)
    a = read(), b = read(), add(i, a, b), add(a, i, b);
  dp[rt] = sum = n;
  getroot();
  divide();
  writeln(ans);
}