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;
const long long mod0 = 1e9 + 7;
const long long mod1 = 998244353;
const long long mod2 = 1e9 + 9;
const long long mod3 = 2147483647;
const int maxn = 1e5 + 3;
const long long inf = 2 * 1024 * 1024 * 1023 - 1;
const long long INF = inf * inf;
const long double eps = 1e-7;
void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(16);
}
int n, L, W;
vector<int> first(maxn), nd(maxn), sz(100001), msz(100001), v(100001),
    d1(100010), d2(100001), dv(100001);
vector<int> nxt(2 * maxn), to(2 * maxn), from(2 * maxn);
int idx, num;
long long ans;
void add(int x, int y, int p) {
  nxt[++idx] = first[x];
  first[x] = idx;
  to[idx] = y;
  from[idx] = p;
  nxt[++idx] = first[y];
  first[y] = idx;
  to[idx] = x;
  from[idx] = p;
}
void insert(int x, int p) {
  for (++x; x <= n + 1; x += x & -x) v[x] += p;
}
int ask(int x) {
  int result = 0;
  for (++x; x; x -= x & -x) result += v[x];
  return result;
}
void dfs(int x, int pr) {
  sz[x] = 1;
  msz[x] = 0;
  for (int i = first[x]; i > 0; i = nxt[i]) {
    if (dv[to[i]]) continue;
    if (to[i] != pr) {
      d1[to[i]] = d1[x] + 1;
      d2[to[i]] = d2[x] + from[i];
      dfs(to[i], x);
      sz[x] += sz[to[i]];
      msz[x] = max(msz[x], sz[to[i]]);
    }
  }
  nd[++num] = x;
}
bool cmp(int x, int y) { return d2[x] < d2[y]; }
void getans(int z) {
  vector<int> nd1(num);
  for (int i = 1; i <= num; ++i) nd1[i - 1] = nd[i];
  sort(nd1.begin(), nd1.end(), cmp);
  for (int i = 1; i <= num; ++i) nd[i] = nd1[i - 1];
  int j = 0;
  for (int i = num; i > 0; --i) {
    while (j < num && d2[nd[i]] + d2[nd[j + 1]] <= W) {
      insert(d1[nd[++j]], 1);
    }
    if (d1[nd[i]] <= L) ans += z * ask(L - d1[nd[i]]);
  }
  while (j > 0) insert(d1[nd[j--]], -1);
}
void solve(int x) {
  num = 0;
  dfs(x, -1);
  int N = sz[x], rt = x;
  for (int i = 1; i <= num; i++) {
    if (max(msz[rt], N - msz[rt]) > max(msz[nd[i]], N - msz[nd[i]])) rt = nd[i];
  }
  num = 0;
  d1[rt] = d2[rt] = 0;
  dv[rt] = true;
  dfs(rt, -1);
  getans(1);
  for (int i = first[rt]; i > 0; i = nxt[i]) {
    if (dv[to[i]]) continue;
    num = 0;
    dfs(to[i], -1);
    getans(-1);
  }
  for (int i = first[rt]; i > 0; i = nxt[i]) {
    if (dv[to[i]]) continue;
    solve(to[i]);
  }
}
int main() {
  init();
  cin >> n >> L >> W;
  for (int i = 1; i < n; i++) {
    int p0, w0;
    cin >> p0 >> w0;
    add(p0, i + 1, w0);
  }
  solve(1);
  cout << ((ans - n) / 2) << endl;
}