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 target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
using namespace std;
const int INF = 2e9;
const double eps = 1e-12;
template <typename T>
inline void read(T &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}
const long long N = 100010;
long long n, L, W;
long long head[N], nxt[N << 1], to[N << 1], co[N << 1], lst = 0;
inline void adde(long long x, long long y, long long c) {
  nxt[++lst] = head[x];
  to[lst] = y;
  co[lst] = c;
  head[x] = lst;
}
pair<long long, long long> val[N];
long long ind = 0;
long long has[N], ls = 0;
bool vis[N];
long long Rt;
long long sz[N], all = 0;
void Build(long long u) {
  vis[u] = 1;
  sz[u] = 1;
  for (long long i = head[u]; i; i = nxt[i])
    if (!vis[to[i]]) {
      long long v = to[i];
      Build(v);
      sz[u] += sz[v];
    }
  vis[u] = 0;
}
long long Max_sz[N];
long long Find(long long u) {
  vis[u] = 1;
  Max_sz[u] = 0;
  long long Max_pos = 0;
  for (long long i = head[u]; i; i = nxt[i])
    if (!vis[to[i]]) {
      long long v = to[i];
      Max_sz[u] = max(Max_sz[u], sz[v]);
      long long t = Find(v);
      if (!Max_pos || Max_sz[t] < Max_sz[Max_pos]) Max_pos = t;
    }
  Max_sz[u] = max(Max_sz[u], all - sz[u]);
  if (!Max_pos || Max_sz[u] < Max_sz[Max_pos]) Max_pos = u;
  vis[u] = 0;
  return Max_pos;
}
void dfs(long long u, long long cur, long long dep) {
  vis[u] = 1;
  val[++ind] = make_pair(cur, dep);
  for (long long i = head[u]; i; i = nxt[i])
    if (!vis[to[i]]) {
      dfs(to[i], cur + co[i], dep + 1);
    }
  vis[u] = 0;
}
long long c[N];
inline void Add(long long u, long long v) {
  while (u <= L + 1) {
    c[u] += v;
    u += ((u) & (-u));
  }
}
inline long long Query(long long u) {
  long long ret = 0;
  while (u >= 1) {
    ret += c[u];
    u -= ((u) & (-u));
  }
  return ret;
}
inline long long work(long long u, long long type, long long vv) {
  long long ret = 0;
  ind = 0;
  if (type == 1)
    dfs(u, vv, 1);
  else
    dfs(u, 0, 0);
  sort(val + 1, val + ind + 1);
  long long cur = ind;
  for (long long i = 1; i <= ind; i++) Add(val[i].second + 1, 1);
  long long cnt = 0;
  for (long long p = 1; p <= ind; p++) {
    while (val[cur].first + val[p].first > W && cur > p) {
      ++cnt;
      Add(val[cur].second + 1, -1);
      --cur;
    }
    Add(val[p].second + 1, -1);
    ++cnt;
    if (L - val[p].second >= 0) ret += Query(L - val[p].second + 1);
    if (p == cur) break;
  }
  assert(cnt == ind);
  return ret;
}
long long ans = 0;
void Work(long long u) {
  Build(u);
  all = sz[u];
  Rt = Find(u);
  ans += work(Rt, 0, 0);
  vis[Rt] = 1;
  ind = 0;
  for (long long i = head[Rt]; i; i = nxt[i])
    if (!vis[to[i]]) ans -= work(to[i], 1, co[i]);
  for (long long i = head[Rt]; i; i = nxt[i])
    if (!vis[to[i]]) Work(to[i]);
}
char s[N];
signed main() {
  read(n);
  read(L);
  read(W);
  L = min(L, n - 1);
  for (long long i = 2; i <= n; i++) {
    long long x, y;
    read(x);
    read(y);
    adde(i, x, y);
    adde(x, i, y);
  }
  Work(1);
  printf("%lld\n", ans);
  return 0;
}