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 <class T>
inline bool chkmin(T &x, T y) {
  return y < x ? x = y, 1 : 0;
}
template <class T>
inline bool chkmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
inline long long Max(long long x, long long y) { return x > y ? x : y; }
inline long long Min(long long x, long long y) { return x < y ? x : y; }
int n, W, L;
struct edge {
  int to, w;
};
vector<edge> E[100002];
int sz[100002], F[100002];
bool vis[100002];
int size, root;
long long ans;
int tim;
struct que {
  int len, w;
  bool operator<(const que &_) const { return w < _.w; }
} Q[100002];
struct Tree {
  long long sum[100002];
  void add(int x, int res) {
    while (x <= n + 1) {
      sum[x] += res;
      x += x & -x;
    }
  }
  long long query(int x) {
    long long res = 0;
    while (x) res += sum[x], x -= x & -x;
    return res;
  }
} T;
void getroot(int x, int f) {
  sz[x] = 1;
  F[x] = 0;
  for (int i = (0), i_end_ = (E[x].size()); i < i_end_; i++) {
    int y = E[x][i].to;
    if (y == f || vis[y]) continue;
    getroot(y, x);
    sz[x] += sz[y];
    chkmax(F[x], sz[y]);
  }
  chkmax(F[x], size - sz[x]);
  if (F[x] < F[root]) root = x;
}
void getdeep(int x, int f, int w, int len) {
  T.add(len + 1, 1);
  Q[++tim] = (que){len, w};
  for (int i = (0), i_end_ = (E[x].size()); i < i_end_; i++) {
    int y = E[x][i].to;
    if (y == f || vis[y]) continue;
    getdeep(y, x, w + E[x][i].w, len + 1);
  }
}
long long calc(int x, int v, int d) {
  tim = 0;
  getdeep(x, 0, v, d);
  long long res = 0;
  sort(Q + 1, Q + tim + 1);
  int l = 1, r = tim;
  T.add(Q[1].len + 1, -1);
  while (l < r) {
    if (Q[l].w + Q[r].w <= L) {
      if (Q[l].len <= W) res += T.query(W - Q[l].len + 1);
      l++;
      T.add(Q[l].len + 1, -1);
    } else {
      T.add(Q[r].len + 1, -1);
      r--;
    }
  }
  return res;
}
void solve(int x) {
  vis[x] = 1;
  ans += calc(x, 0, 0);
  for (int i = (0), i_end_ = (E[x].size()); i < i_end_; i++) {
    int y = E[x][i].to;
    if (vis[y]) continue;
    ans -= calc(y, E[x][i].w, 1);
    root = 0;
    size = sz[y];
    getroot(y, 0);
    solve(root);
  }
}
void Clear() {
  size = n;
  root = 0;
  F[0] = n + 1;
}
int main() {
  scanf("%d%d%d", &n, &W, &L);
  for (int i = (2), i_end_ = (n); i <= i_end_; i++) {
    int f, v;
    scanf("%d%d", &f, &v);
    E[i].push_back((edge){f, v});
    E[f].push_back((edge){i, v});
  }
  Clear();
  getroot(1, 0);
  solve(root);
  printf("%lld\n", ans);
  return 0;
}