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
#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long maxn = 1e5 + 123;
const long long inf = 1e9 + 123;
const long long linf = 1e18 + 123;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
const double pi = acos(-1);
int dx[8] = {0, 1, -1, 0, 1, -1, 1, -1};
int dy[8] = {1, 0, 0, -1, 1, 1, -1, -1};
long long n, l, w, level[maxn], parent[maxn], d[maxn], ans, L[maxn], W[maxn],
    t[maxn];
vector<pair<int, int> > g[maxn];
void update(int pos, int val) {
  for (; pos <= n; pos |= (pos + 1)) {
    t[pos] += val;
  }
}
long long get(int pos) {
  int res = 0;
  for (; pos >= 0; pos = (pos & (pos + 1)) - 1) {
    res += t[pos];
  }
  return res;
}
void dfs(int v, int p) {
  d[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first;
    if (to == p) {
      continue;
    }
    dfs(to, v);
    d[v] += d[to];
  }
}
int find_center(int v) {
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first;
    if (level[to] == -1 && d[to] > d[v] / 2) {
      d[v] -= d[to];
      d[to] += d[v];
      return find_center(to);
    }
  }
  return v;
}
void dfs2(int v, int pr, vector<int> &p) {
  p.push_back(v);
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first;
    if (level[to] != -1 || to == pr) {
      continue;
    }
    L[to] = L[v] + 1;
    W[to] = W[v] + g[v][i].second;
    dfs2(to, v, p);
  }
}
bool cmp(pair<int, pair<int, int> > x, pair<int, pair<int, int> > y) {
  if (x.second.second != y.second.second) {
    return x.second.second < y.second.second;
  }
  return x.first < y.first;
}
long long ANS(vector<int> p) {
  vector<pair<int, pair<int, int> > > v;
  for (int i = 0; i < p.size(); i++) {
    v.push_back({1, {L[p[i]], W[p[i]]}});
    v.push_back({2, {l - L[p[i]], w - W[p[i]]}});
  }
  long long res = 0;
  sort(v.begin(), v.end(), &cmp);
  for (int i = 0; i < v.size(); i++) {
    if (v[i].first == 1) {
      update(v[i].second.first, 1);
    } else {
      res += get(v[i].second.first);
    }
  }
  for (int i = 0; i < v.size(); i++) {
    if (v[i].first == 1) {
      update(v[i].second.first, -1);
    }
  }
  return res;
}
void build(int v, int depth, int p) {
  v = find_center(v);
  parent[v] = p;
  level[v] = depth;
  L[v] = 0;
  W[v] = 0;
  vector<int> P;
  P.push_back(v);
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first;
    if (level[to] != -1) {
      continue;
    }
    L[to] = L[v] + 1;
    W[to] = W[v] + g[v][i].second;
    dfs2(to, v, P);
  }
  ans += ANS(P);
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first;
    if (level[to] != -1) {
      continue;
    }
    P.clear();
    dfs2(to, v, P);
    ans -= ANS(P);
  }
  ans--;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first;
    if (level[to] != -1) {
      continue;
    }
    build(to, depth + 1, v);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> l >> w;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    g[i + 1].push_back({x, y});
    g[x].push_back({i + 1, y});
    level[i] = -1;
  }
  level[n] = -1;
  dfs(1, -1);
  build(1, 0, -1);
  cout << ans / 2;
  exit(0);
}
