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 std::sort;
struct Edge {
  int v, w, next;
} e[200002];
int ecnt, h[100002];
inline void add_edge(int u, int v, int w) {
  e[++ecnt] = {v, w, h[u]};
  h[u] = ecnt;
  e[++ecnt] = {u, w, h[v]};
  h[v] = ecnt;
}
int size[100002], dis1[100002], dis2[100002], dp[100002];
int L, W;
int node[100002], cnt;
bool vis[100002];
inline int max(int x, int y) { return x > y ? x : y; }
void get_root(int u, int fa, int s, int &cur) {
  size[u] = 1, dp[u] = 0;
  for (int i = h[u]; i; i = e[i].next)
    if (!vis[e[i].v] && e[i].v != fa)
      get_root(e[i].v, u, s, cur), size[u] += size[e[i].v],
          dp[u] = max(dp[u], size[e[i].v]);
  dp[u] = max(dp[u], s - size[u]);
  if (dp[u] < dp[cur]) cur = u;
}
void fill(int u, int fa, int w) {
  size[u] = 1;
  dis1[u] = dis1[fa] + w;
  dis2[u] = dis2[fa] + 1;
  for (int i = h[u]; i; i = e[i].next)
    if (!vis[e[i].v] && e[i].v != fa)
      fill(e[i].v, u, e[i].w), size[u] += size[e[i].v];
}
void get_node(int u, int fa) {
  node[++cnt] = u;
  for (int i = h[u]; i; i = e[i].next)
    if (!vis[e[i].v] && e[i].v != fa) get_node(e[i].v, u);
}
inline bool cmp(int u, int v) { return dis1[u] < dis1[v]; }
int c[100002];
inline void add(int x, int v) {
  x++;
  for (; x <= 100000; x += ((x) & -(x))) c[x] += v;
}
inline int sum(int x) {
  x++;
  if (x <= 0) return 0;
  int ans = 0;
  for (; x > 0; x -= ((x) & -(x))) ans += c[x];
  return ans;
}
long long Ans;
inline long long solve() {
  long long ans = 0;
  sort(node + 1, node + cnt + 1, cmp);
  for (int i = 1; i <= cnt; i++) add(dis2[node[i]], 1);
  int i = 1, j = cnt;
  while (i < j) {
    if (dis1[node[i]] + dis1[node[j]] <= W) {
      add(dis2[node[i]], -1);
      ans += sum(L - dis2[node[i]]);
      i++;
    } else {
      add(dis2[node[j]], -1);
      j--;
    }
  }
  add(dis2[node[j]], -1);
  return ans;
}
inline void clear() { cnt = 0; }
void dfs(int u) {
  dis1[u] = dis2[u] = 0;
  fill(u, 0, 0);
  for (int i = h[u]; i; i = e[i].next)
    if (!vis[e[i].v]) get_node(e[i].v, u), Ans -= solve(), clear();
  get_node(u, 0), Ans += solve(), clear();
  vis[u] = 1;
  for (int i = h[u]; i; i = e[i].next)
    if (!vis[e[i].v]) {
      int rt = 0;
      get_root(e[i].v, 0, size[e[i].v], rt);
      dfs(rt);
    }
}
int main() {
  int n, tu, tw;
  dp[0] = 114514;
  dis2[0] = -1;
  scanf("%d%d%d", &n, &L, &W);
  for (int i = 2; i <= n; i++) scanf("%d%d", &tu, &tw), add_edge(i, tu, tw);
  int rt = 0;
  get_root(1, 0, n, rt);
  dfs(rt);
  printf("%I64d", Ans);
  return 0;
}