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;
int n, l, w, mx, root, top, dis[100005], f[100005], son[100005], num, ti;
bool vis[100005];
long long ans, sum[100005], tree[100005];
struct edge {
  int to, v;
};
struct P {
  long long sum;
  int dis;
  bool operator<(const P &x) const {
    return sum < x.sum || (sum == x.sum && dis < x.dis);
  }
} t[100005];
vector<edge> e[100005];
inline char nc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int read() {
  int a = 0;
  char f = 1, c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    a = a * 10 + c - '0';
    c = getchar();
  }
  return a * f;
}
inline void addedge(int x, int y, int v) {
  e[x].push_back((edge){y, v});
  e[y].push_back((edge){x, v});
}
inline void getroot(int x, int fa) {
  son[x] = 1, f[x] = 0;
  for (int i = 0; i < e[x].size(); ++i)
    if (!vis[e[x][i].to] && e[x][i].to != fa) {
      getroot(e[x][i].to, x);
      son[x] += son[e[x][i].to];
      f[x] = max(f[x], son[e[x][i].to]);
    }
  f[x] = max(f[x], num - son[x]);
  if (f[x] < f[root]) root = x;
}
void dfs(int x, int fa, int dis, long long sum) {
  t[++top] = (P){sum, dis};
  mx = max(mx, dis);
  for (int i = 0; i < e[x].size(); ++i)
    if (!vis[e[x][i].to] && e[x][i].to != fa)
      dfs(e[x][i].to, x, dis + 1, sum + e[x][i].v);
}
inline void add(int x, int y) {
  ++x;
  for (; x <= mx + 1; x += x & -x) {
    tree[x] += y;
  }
}
inline long long ask(int x) {
  long long res = 0;
  ++x;
  if (x <= 0) return 0;
  for (; x; x -= x & -x) res += tree[x];
  return res;
}
inline long long calc(int x, int d, int v) {
  mx = 0;
  top = 0;
  dfs(x, 0, d, v);
  sort(t + 1, t + top + 1);
  for (int i = 0; i <= mx + 1; ++i) tree[i] = 0;
  long long res = 0;
  for (int i = 1; i <= top; ++i) add(t[i].dis, 1);
  for (int i = 1, j = top; i <= top; ++i) {
    while (j && t[i].sum + t[j].sum > w) add(t[j].dis, -1), --j;
    if (i >= j) break;
    add(t[i].dis, -1);
    res += ask(min(l - t[i].dis, mx));
  }
  return res;
}
inline void solve(int x) {
  ans += calc(x, 0, 0);
  vis[x] = 1;
  for (int i = 0; i < e[x].size(); ++i)
    if (!vis[e[x][i].to]) {
      edge v = e[x][i];
      ans -= calc(v.to, 1, v.v);
      num = son[v.to];
      root = 0;
      getroot(v.to, 0);
      solve(root);
    }
}
int main() {
  n = read(), l = read(), w = read();
  for (int i = 1; i < n; ++i) {
    int p = read(), v = read();
    addedge(i + 1, p, v);
  }
  num = n, root = 0, f[0] = 2e9;
  getroot(1, 0);
  solve(root);
  printf("%I64d\n", ans);
  return 0;
}