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 = 100010, MaxM = 200010, Inf = 1 << 30;
long long Ans;
class Tree_Array {
 public:
  int C[MaxN], Time[MaxN], SumTime, N;
  void Init(int Size) {
    N = Size + 1;
    SumTime++;
  }
  void MakeLazy(int Now) {
    if (Time[Now] != SumTime) {
      Time[Now] = SumTime;
      C[Now] = 0;
    }
  }
  void Insert(int Now) {
    Now++;
    for (; Now <= N; Now += (Now & -Now)) {
      MakeLazy(Now);
      C[Now]++;
    }
  }
  int Query(int Now) {
    if (Now < 0) return 0;
    if (Now >= N) Now = N - 1;
    Now++;
    int Ret = 0;
    for (; Now; Now -= (Now & -Now)) {
      MakeLazy(Now);
      Ret += C[Now];
    }
    return Ret;
  }
} T;
int En[MaxN], Next[MaxM], Point[MaxM], V[MaxM], Tot;
int N, QL, QW;
bool Mark[MaxN];
void Add(int X, int Y, int Z) {
  Next[++Tot] = En[X];
  En[X] = Tot;
  Point[Tot] = Y;
  V[Tot] = Z;
}
int Time[MaxN], SumTime, STot, S[MaxN], Size[MaxN], MaxSize[MaxN];
void Dfs_Size(int Now) {
  Time[Now] = SumTime;
  Size[Now] = 1;
  MaxSize[Now] = 0;
  S[++STot] = Now;
  for (int i = En[Now]; i; i = Next[i])
    if (!Mark[Point[i]] && (Time[Point[i]] != SumTime)) {
      Dfs_Size(Point[i]);
      Size[Now] += Size[Point[i]];
      MaxSize[Now] = max(MaxSize[Now], Size[Point[i]]);
    }
}
int FindRoot(int Now) {
  STot = 0;
  SumTime++;
  Dfs_Size(Now);
  int Ret = Now, MinSize = Inf;
  for (int i = 1; i <= STot; i++) {
    MaxSize[S[i]] = max(MaxSize[S[i]], Size[Now] - Size[S[i]]);
    if (MaxSize[S[i]] < MinSize) {
      MinSize = MaxSize[S[i]];
      Ret = S[i];
    }
  }
  return Ret;
}
struct Node {
  int Size, Len;
  bool operator<(const Node &A) const { return Len < A.Len; }
} H[MaxN];
int HTot;
void Dfs_GetH(int Now, int Len, int W) {
  H[++HTot] = (Node){Len, W};
  Time[Now] = SumTime;
  for (int i = En[Now]; i; i = Next[i])
    if (!Mark[Point[i]] && (Time[Point[i]] != SumTime))
      Dfs_GetH(Point[i], Len + 1, W + V[i]);
}
long long Calc(int L, int R) {
  long long Ret = 0;
  sort(H + L, H + R + 1);
  int MaxSize = 0;
  for (int i = L; i <= R; i++)
    if (H[i].Size > MaxSize) MaxSize = H[i].Size;
  T.Init(MaxSize);
  int Pos = L - 1;
  for (int i = R; i >= L; i--) {
    while ((Pos < R) && (H[Pos + 1].Len + H[i].Len <= QW)) {
      Pos++;
      T.Insert(H[Pos].Size);
    }
    Ret += T.Query(QL - H[i].Size);
    if ((H[i].Size * 2 <= QL) && (H[i].Len * 2 <= QW)) Ret--;
  }
  return Ret;
}
void Solve(int Now) {
  SumTime++;
  HTot = 0;
  int Last = 1;
  for (int i = En[Now]; i; i = Next[i])
    if (!Mark[Point[i]]) {
      Dfs_GetH(Point[i], 1, V[i]);
      Ans -= Calc(Last, HTot);
      Last = HTot + 1;
    }
  H[++HTot] = (Node){0, 0};
  Ans += Calc(1, HTot);
}
void Dac(int Now) {
  Now = FindRoot(Now);
  Mark[Now] = 1;
  Solve(Now);
  for (int i = En[Now]; i; i = Next[i])
    if (!Mark[Point[i]]) Dac(Point[i]);
}
int main() {
  scanf("%d%d%d", &N, &QL, &QW);
  for (int i = 1; i < N; i++) {
    int U, W;
    scanf("%d%d", &U, &W);
    Add(i + 1, U, W);
    Add(U, i + 1, W);
  }
  Dac(1);
  cout << Ans / 2 << endl;
  return 0;
}