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;
struct Fenwick {
  int a[101010], n;
  void init(int sz) {
    n = sz;
    memset(a, 0, (n + 1) * sizeof(a[0]));
  }
  void add(int j) {
    for (int k = j; k <= n; k += k & -k) a[k]++;
  }
  int calc(int j) {
    int rlt = 0;
    for (int k = j; k; k -= k & -k) rlt += a[k];
    return rlt;
  }
} Fen;
int id[101010], tmp[101010];
int *cmp_pos;
bool cmp(int i, int j) { return cmp_pos[i] < cmp_pos[j]; }
struct Problem {
  int n, m;
  pair<int, int> p[101010], q[101010];
  void add_pnt(pair<int, int> a) { p[++n] = a; }
  void add_query(pair<int, int> a) { q[++m] = a; }
  long long solve() {
    sort(p + 1, p + n + 1);
    sort(q + 1, q + m + 1);
    int mx = 0;
    for (int i = 1; i <= n; i++) mx = max(mx, p[i].second);
    Fen.init(mx);
    long long rlt = 0;
    for (int e = 1, f = 1; f <= m; f++) {
      while (e <= n && p[e].first <= q[f].first) Fen.add(p[e++].second);
      rlt += Fen.calc(min(q[f].second, mx));
    }
    return rlt;
  }
} P;
vector<int> v[101010], w[101010];
int n, X, Y;
bool del[101010];
vector<pair<int, int> > S, TMP;
void DFS(int x, int fa, int len, int wei) {
  if (len > X || wei > Y) return;
  TMP.push_back(make_pair(len, wei));
  for (int i = 0, y, z; i < v[x].size(); i++) {
    y = v[x][i], z = w[x][i];
    if (y == fa || del[y]) continue;
    DFS(y, x, len + 1, wei + z);
  }
}
long long query(vector<pair<int, int> > &v) {
  P.n = P.m = 0;
  for (int i = 0; i < v.size(); i++)
    P.add_pnt(make_pair(v[i].second, v[i].first + 1)),
        P.add_query(make_pair(Y - v[i].second, 1 + X - v[i].first));
  return P.solve();
}
long long ans;
void calc(int x) {
  S.clear();
  for (int i = 0, y, z; i < v[x].size(); i++) {
    y = v[x][i], z = w[x][i];
    if (del[y]) continue;
    TMP.clear();
    DFS(y, x, 1, z);
    ans -= query(TMP);
    for (int j = 0; j < TMP.size(); j++) S.push_back(TMP[j]);
  }
  ans += query(S);
  ans += S.size() * 2;
}
int nodes, node[101010], ms[101010], sz[101010];
void dfs(int x, int fa = 0) {
  node[++nodes] = x;
  ms[x] = 0, sz[x] = 1;
  for (int i = 0, y; i < v[x].size(); i++) {
    y = v[x][i];
    if (y == fa || del[y]) continue;
    dfs(y, x);
    sz[x] += sz[y];
    ms[x] = max(ms[x], sz[y]);
  }
}
void solve(int x) {
  nodes = 0;
  dfs(x);
  int rt = 0;
  for (int i = 1, tmp; i <= nodes; i++) {
    if (max(ms[node[i]], nodes - sz[node[i]]) <= nodes / 2) {
      rt = node[i];
      break;
    }
  }
  del[rt] = 1;
  calc(rt);
  for (int i = 0, y; i < v[rt].size(); i++) {
    y = v[rt][i];
    if (del[y]) continue;
    solve(y);
  }
}
int main() {
  scanf("%d %d %d", &n, &X, &Y);
  for (int i = 2, j, z; i <= n; i++) {
    scanf("%d %d", &j, &z);
    v[i].push_back(j);
    v[j].push_back(i);
    w[i].push_back(z);
    w[j].push_back(z);
  }
  ans = 0;
  solve(1);
  printf("%I64d\n", ans / 2);
  return 0;
}