#include<bits/stdc++.h>

using namespace std;

typedef long long llint;

const int MAXN = 51;
const llint INF = 1000000000000000000LL;

llint n, x, d, sol;
llint val[MAXN], cost[MAXN], par[MAXN], lim[MAXN], br[MAXN];
llint dp[MAXN][MAXN * MAXN * MAXN];
int r[MAXN];

void calc () {
    for (int w = 1; w <= 125000; w++) dp[0][w] = INF;
    for (int pos = 1; pos <= n; pos++) {
        for (int w = 0; w <= 125000; w++) {
            llint res = INF;
            int to = min((llint) w / val[pos], br[pos]);
            for (int take = 0; take <= to; take++) {
                res = min(res, dp[pos - 1][w - take * val[pos]] + take * cost[pos]);
            }
            dp[pos][w] = res;
        }
    }
}

bool cmp (int x, int y) {
    return val[x] * cost[y] > val[y] * cost[x];
}

llint f (llint ost) {
    llint res = 0;
    for (int i = 1; i <= n; i++) {
        int ind = r[i];
        int take = min(ost / cost[ind], br[ind]);
        res += take * val[ind];
        ost -= take * cost[ind];
    }
    return res;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> x >> d;
    lim[1] = INF;
    for (int i = 1; i <= n; i++) {
        r[i] = i;
        cin >> cost[i];
        if (i > 1) cin >> par[i];
        if (i > 1) lim[i] = d;
    }
    for (int i = n; i >= 1; i--) {
        val[i]++;
        br[i] = min(lim[i], 50LL);
        val[par[i]] += val[i];
        cost[par[i]] += cost[i];
    }
    sort(r + 1, r + 1 + n, cmp);
    calc();
    for (int i = 1; i <= n; i++) {
        br[i] = max(0LL, lim[i] - 50);
    }
    for (int w = 0; w <= 125000; w++) {
        if (dp[n][w] <= x) {
            sol = max(sol, w + f(x - dp[n][w]));
        }
    }
    cout << sol;
    return 0;
}
