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;
using pii = pair<int, int>;
using ll = long long;
const int N = 100 * 1000 + 10;
int n, L, W, sz[N], fen[N];
vector<pii> adj[N], sub;
vector<int> del;
multiset<pii> sv;
bool vis[N];
ll ans;
void add(int x, int k) {
  for (; x < N; x += x & -x) fen[x] += k;
}
int get(int x) {
  int res = 0;
  for (; x; x -= x & -x) res += fen[x];
  return res;
}
void dfs_sz(int v, int par = -1) {
  sz[v] = 1;
  for (auto [u, w] : adj[v])
    if (u ^ par && !vis[u]) dfs_sz(u, v), sz[v] += sz[u];
}
int find_cen(int v, int par, int x) {
  bool fnd = 0;
  while (!fnd) {
    fnd = 1;
    for (auto [u, w] : adj[v])
      if (u ^ par && sz[u] > x && !vis[u]) {
        fnd = 0, par = v, v = u;
        break;
      }
  }
  return v;
}
void dfs_cal(int v, int par, int sm, int len) {
  sub.push_back({sm, len}), ans++;
  for (auto [u, w] : adj[v])
    if (u ^ par && !vis[u] && sm + w <= W && len < L)
      dfs_cal(u, v, sm + w, len + 1);
}
void cal() {
  sort(sub.begin(), sub.end(), greater<pii>());
  int sz = sub.size();
  auto l = sv.begin();
  for (int r = 0; r < sz; r++) {
    while (l != sv.end() && l->first + sub[r].first <= W)
      del.push_back(l->second), add(l->second, 1), l++;
    ans += get(L - sub[r].second);
  }
  for (int i = 0; i < sz; i++) sv.insert(sub[i]);
  for (int l : del) add(l, -1);
  sub.clear(), del.clear();
}
void solve(int v = 0) {
  dfs_sz(v);
  v = find_cen(v, -1, sz[v] / 2);
  vis[v] = 1;
  for (auto [u, w] : adj[v])
    if (!vis[u] && w <= W && 1 <= L) dfs_cal(u, v, w, 1), cal();
  sv.clear();
  for (auto [u, w] : adj[v])
    if (!vis[u]) solve(u);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> n >> L >> W;
  for (int i = 1, u, w; i < n; i++)
    cin >> u >> w, adj[--u].push_back({i, w}), adj[i].push_back({u, w});
  solve();
  cout << ans << '\n';
}