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;
const int maxn = 100100;
int n, l, w;
int head[maxn], nxt[maxn << 1], ver[maxn << 1], val[maxn << 1], tot;
inline void addedge(int a, int b, int c) {
  nxt[++tot] = head[a];
  ver[tot] = b;
  val[tot] = c;
  head[a] = tot;
  nxt[++tot] = head[b];
  ver[tot] = a;
  val[tot] = c;
  head[b] = tot;
}
vector<pair<int, long long> > v;
inline int cmp(const pair<int, long long> &a, const pair<int, long long> &b) {
  return a.second == b.second ? a.first < b.first : a.second < b.second;
}
inline int lowbit(int x) { return x & -x; }
struct Bitarray {
  int c[maxn], N;
  inline void resize(int n) {
    N = n + 1;
    for (int i = 1; i <= n + 1; i++) c[i] = 0;
  }
  inline void add(int x, int v) {
    x++;
    for (; x <= N; x += lowbit(x)) c[x] += v;
  }
  inline int query(int x) {
    x++;
    x = min(x, N);
    int ans = 0;
    for (; x; x -= lowbit(x)) ans += c[x];
    return ans;
  }
} bit;
inline long long getans() {
  long long ans = 0;
  int mxv = 0, nowr = v.size();
  for (int i = 0; i < (int)v.size(); i++) mxv = max(mxv, v[i].first);
  bit.resize(mxv);
  sort(v.begin(), v.end(), cmp);
  for (int i = 0; i < (int)v.size(); i++) bit.add(v[i].first, 1);
  for (int i = 0; i < (int)v.size(); i++) {
    bit.add(v[i].first, -1);
    while (nowr && v[nowr - 1].second + v[i].second > w)
      nowr--, bit.add(v[nowr].first, -1);
    if (i >= nowr) break;
    if (v[i].first <= l) ans += bit.query(l - v[i].first);
  }
  return ans;
}
int size[maxn];
bool vis[maxn];
inline void getroot(int x, int fat, int &rt, int &mnv, int allsize) {
  size[x] = 1;
  int v = 0;
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (vis[y] || y == fat) continue;
    getroot(y, x, rt, mnv, allsize);
    size[x] += size[y];
    v = max(v, size[y]);
  }
  v = max(v, allsize - size[x]);
  if (v < mnv) rt = x, mnv = min(mnv, v);
}
inline int dfs(int x, int fat, int nowe, long long nowd) {
  int ans = 1;
  v.push_back(make_pair(nowe, nowd));
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (y == fat || vis[y]) continue;
    ans += dfs(y, x, nowe + 1, nowd + val[i]);
  }
  return ans;
}
long long ans = 0;
inline void solve(int x) {
  v.clear();
  dfs(x, 0, 0, 0);
  ans += getans();
  vis[x] = 1;
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (vis[y]) continue;
    int rt = y, mnv = 2e9;
    v.clear();
    int allsize = dfs(y, x, 1, val[i]);
    ans -= getans();
    getroot(y, x, rt, mnv, allsize);
    solve(rt);
  }
}
int main() {
  scanf("%d%d%d", &n, &l, &w);
  for (int i = 2, a, b; i <= n; i++) scanf("%d%d", &a, &b), addedge(i, a, b);
  solve(1);
  printf("%lld\n", ans);
  return 0;
}