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;
inline long long in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
const long long N = 1e5 + 7;
long long n, Q, l, w;
vector<long long> g[N], gg[N];
long long sz[N], mark[N], ans, dis[N], wi[N];
inline long long SZ(long long x, long long par) {
  sz[x] = 1;
  for (auto i : g[x])
    if (i != par && !mark[i]) sz[x] += SZ(i, x);
  return sz[x];
}
inline void DIS(long long x, long long par) {
  for (long long i = 0; i < ((long long)g[x].size()); i++)
    if (g[x][i] != par && !mark[g[x][i]]) {
      dis[g[x][i]] = dis[x] + 1;
      wi[g[x][i]] = wi[x] + gg[x][i];
      DIS(g[x][i], x);
    }
}
long long fen[N];
inline void add(long long x, long long y) {
  x++;
  for (long long i = x; i < N; i += i & -i) fen[i] += y;
}
inline long long get(long long x) {
  x++;
  if (x < 1) return 0;
  long long res = 0;
  for (long long i = x; i; i -= i & -i) res += fen[i];
  return res;
}
vector<pair<long long, long long> > v;
inline void calc(long long sgn) {
  sort(v.begin(), v.end());
  if (0) cerr << "*\n";
  for (auto i : v) {
    add(i.second, 1);
    if (0) cerr << i.first << '&' << i.second << endl;
  }
  long long pos = ((long long)v.size()) - 1, res = 0;
  for (long long i = 0; i < ((long long)v.size()); i++) {
    while (v[i].first + v[pos].first > w && pos >= 0) {
      if (0) cerr << v[i].first << ' ' << v[pos].first << endl;
      add(v[pos--].second, -1);
    }
    ans += sgn * get(l - v[i].second);
    res += get(l - v[i].second);
  }
  if (0) cerr << '#' << res << endl;
  while (pos >= 0) {
    add(v[pos--].second, -1);
  }
}
inline void dfs(long long x, long long par) {
  v.push_back({wi[x], dis[x]});
  for (auto i : g[x])
    if (i != par && !mark[i]) dfs(i, x);
}
inline void solve(long long x, long long par) {
  SZ(x, par);
  long long cen = x, pr = par, found = 0;
  while (!found) {
    found = 1;
    for (auto i : g[cen])
      if (!mark[i] && i != pr && sz[i] >= sz[x] / 2) {
        pr = cen;
        cen = i;
        found = 0;
        break;
      }
  }
  mark[cen] = 1;
  dis[cen] = 0;
  wi[cen] = 0;
  DIS(cen, -1);
  vector<pair<long long, long long> > o;
  if (0) cerr << "cen " << cen << endl;
  for (auto i : g[cen])
    if (!mark[i]) {
      dfs(i, cen);
      calc(-1);
      while (v.size()) {
        o.push_back(v.back());
        v.pop_back();
      }
    }
  o.push_back({0, 0});
  v = o;
  calc(1);
  v.clear();
  for (auto i : g[cen])
    if (!mark[i]) solve(i, cen);
}
int32_t main() {
  n = in(), l = in(), w = in();
  for (long long i = 2; i <= n; i++) {
    long long x = in(), y = in();
    g[i].push_back(x);
    g[x].push_back(i);
    gg[i].push_back(y);
    gg[x].push_back(y);
  }
  solve(1, -1);
  cout << (ans - n) / 2 << endl;
}