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 tree {
  vector<int> g;
  int n;
  void init(int _n) {
    n = _n + 2;
    g.clear();
    g.resize(n + 2);
    for (int i = 0; i < n; ++i) g[i] = 0;
  }
  void add(int x, int v) {
    while (x <= n) g[x] += v, x += x & -x;
  }
  long long sum(int x) {
    long long ret = 0;
    while (x > 0) ret += g[x], x -= x & -x;
    return ret;
  }
} go;
int fst[100010], vv[200020], nxt[200020], cost[200020], e;
void init() { memset(fst, -1, sizeof fst), e = 0; }
void add(int u, int v, int c) {
  vv[e] = v, nxt[e] = fst[u], cost[e] = c, fst[u] = e++;
}
int sz[100010], mx[100010], root, tot;
bool vis[100010];
void dfsS(int u, int p) {
  sz[u] = 1;
  for (int i = fst[u]; ~i; i = nxt[i]) {
    int v = vv[i];
    if (vis[v] || v == p) continue;
    dfsS(v, u);
    sz[u] += sz[v];
  }
}
void dfsR(int u, int p) {
  mx[u] = 0;
  for (int i = fst[u]; ~i; i = nxt[i]) {
    int v = vv[i];
    if (vis[v] || v == p) continue;
    dfsR(v, u);
    mx[u] = max(mx[u], sz[v]);
  }
  mx[u] = max(mx[u], tot - sz[u]);
  if (root == -1 || mx[u] < mx[root]) root = u;
}
int find_root(int u) {
  dfsS(u, -1);
  root = -1, tot = sz[u];
  dfsR(u, -1);
  return root;
}
int cnt;
vector<pair<int, int> > g[100010], all;
void dfs(int u, int p, int w, int num) {
  g[cnt].push_back(make_pair(w, num));
  all.push_back(make_pair(w, num));
  for (int i = fst[u]; ~i; i = nxt[i]) {
    int v = vv[i], c = cost[i];
    if (vis[v] || v == p) continue;
    dfs(v, u, w + c, num + 1);
  }
}
int L, K;
long long ans;
long long gao(vector<pair<int, int> > &g) {
  long long ret = 0;
  int up = 0, n = g.size();
  for (int i = 0; i < n; ++i) up = max(up, g[i].second);
  go.init(up);
  for (int i = 0; i < n; ++i) go.add(g[i].second, 1);
  for (int i = 0, j = n - 1; i < j; ++i) {
    go.add(g[i].second, -1);
    while (j > i && g[i].first + g[j].first > K) {
      go.add(g[j].second, -1);
      j--;
    }
    ret += go.sum(min(up, L - g[i].second));
  }
  return ret;
}
void solve(int u) {
  u = find_root(u);
  vis[u] = 1;
  cnt = 0;
  all.clear();
  for (int i = fst[u]; ~i; i = nxt[i]) {
    int v = vv[i], c = cost[i];
    if (vis[v]) continue;
    g[cnt].clear();
    dfs(v, u, c, 1);
    sort(g[cnt].begin(), g[cnt].end());
    cnt++;
  }
  sort(all.begin(), all.end());
  ans += gao(all);
  for (int i = 0; i < cnt; ++i) {
    for (int j = 0; j < g[i].size(); ++j) {
      if (g[i][j].first <= K && g[i][j].second <= L) ans++;
    }
    ans -= gao(g[i]);
  }
  for (int i = fst[u]; ~i; i = nxt[i]) {
    int v = vv[i];
    if (!vis[v]) solve(v);
  }
}
int main() {
  int n;
  scanf("%d%d%d", &n, &L, &K);
  init();
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(i + 1, u, v);
    add(u, i + 1, v);
  }
  memset(vis, 0, sizeof vis);
  ans = 0;
  solve(1);
  cout << ans << endl;
  return 0;
}