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;
#pragma comment(linker, "/STACK:1024000000,1024000000")
const int maxn = 1e5 + 10;
const int maxm = 2 * maxn;
int first[maxn], tot;
int nxt[maxm], to[maxm], w[maxm];
int n, L, W;
void adde(int u, int v, int ww) {
  to[tot] = v;
  nxt[tot] = first[u];
  w[tot] = ww;
  first[u] = tot++;
}
int siz[maxn], maxs[maxn], vis[maxn];
void dfs(int u, int par) {
  siz[u] = 1;
  maxs[u] = 0;
  for (int i = first[u]; i != -1; i = nxt[i]) {
    int v = to[i];
    if (v == par || vis[v]) continue;
    dfs(v, u);
    siz[u] += siz[v];
    maxs[u] = max(maxs[u], siz[v]);
  }
}
void getrt(int u, int par, int num, int &rt) {
  maxs[u] = max(maxs[u], num - siz[u]);
  if (rt == -1 || maxs[u] < maxs[rt]) rt = u;
  for (int i = first[u]; i != -1; i = nxt[i]) {
    int v = to[i];
    if (v == par || vis[v]) continue;
    getrt(v, u, num, rt);
  }
}
pair<int, int> a[maxn];
int cnt;
void getdep(int u, int par, int dp, int dw) {
  a[cnt++] = pair<int, int>(dw, dp);
  for (int i = first[u]; i != -1; i = nxt[i]) {
    int v = to[i];
    if (vis[v] || v == par) continue;
    getdep(v, u, dp + 1, dw + w[i]);
  }
}
int bit[maxn];
void add(int x, int v) {
  while (x <= n) {
    bit[x] += v;
    x += x & (-x);
  }
}
int sum(int x) {
  if (x <= 0) return 0;
  int ret = 0;
  while (x) {
    ret += bit[x];
    x -= x & (-x);
  }
  return ret;
}
long long count(int l, int r) {
  if (l == r) return 0;
  sort(a + l, a + r);
  for (int i = l; i < r; i++) add(a[i].second, 1);
  int pa = l, pb = r - 1;
  long long ret = 0;
  while (pa < r) {
    while (pb >= pa && a[pa].first + a[pb].first > W) {
      add(a[pb].second, -1);
      pb--;
    }
    if (pb < pa) break;
    ret += sum(L - a[pa].second);
    add(a[pa].second, -1);
    pa++;
  }
  return ret;
}
long long solve(int u) {
  int rt = -1;
  dfs(u, -1);
  getrt(u, -1, siz[u], rt);
  vis[rt] = 1;
  long long ret = 0;
  for (int i = first[rt]; i != -1; i = nxt[i]) {
    int v = to[i];
    if (vis[v]) continue;
    ret += solve(v);
  }
  cnt = 0;
  long long tret = 0;
  for (int i = first[rt]; i != -1; i = nxt[i]) {
    int v = to[i];
    if (vis[v]) continue;
    int tmp = cnt;
    getdep(v, rt, 1, w[i]);
    tret -= count(tmp, cnt);
  }
  tret += count(0, cnt);
  ret += tret;
  for (int i = 0; i < cnt; i++)
    if (a[i].first <= W && a[i].second <= L) ret++;
  vis[rt] = 0;
  return ret;
}
void init() {
  memset(first, -1, sizeof(first));
  tot = 0;
  memset(bit, 0, sizeof(bit));
  memset(vis, 0, sizeof(vis));
}
int main() {
  while (cin >> n >> L >> W) {
    init();
    for (int i = 2; i <= n; i++) {
      int u, ww;
      scanf("%d%d", &u, &ww);
      adde(u, i, ww);
      adde(i, u, ww);
    }
    long long ans = solve(1);
    cout << ans << endl;
  }
  return 0;
}