#include <bits/stdc++.h>
using namespace std;
template<typename T>
void cmax(T &a, const T &b) {
    if (a < b)
        a = b;
}
template<typename T>
void cmin(T &a, const T &b) {
    if (b < a)
        a = b;
}
using LL = long long;
constexpr int MAX_N = 50, MAX_V = MAX_N * MAX_N * MAX_N;
constexpr LL INF = 1E18;
int n, x, d;
LL m[MAX_N];
int p[MAX_N], v[MAX_N], a[MAX_N];
LL f[MAX_V + 1];
void work(LL m, int v) {
    for (int i = n * n * n; i >= v; --i)
        cmin(f[i], f[i - v] + m);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> x >> d;
    cin >> m[0];
    for (int i = 1; i < n; ++i) {
        cin >> m[i] >> p[i];
        --p[i];
    }
    for (int i = n - 1; i >= 1; --i)
        m[p[i]] += m[i];
    for (int i = 0; i < n; ++i)
        v[i] = 1;
    for (int i = n - 1; i >= 1; --i)
        v[p[i]] += v[i];
    for (int i = 0; i < n; ++i)
        a[i] = i;
    sort(a, a + n, [&](int i, int j) {return v[i] * m[j] > v[j] * m[i];});
    fill(f + 1, f + MAX_V + 1, INF);
    for (int i = 0; i < n; ++i) {
        int lim = i == 0 ? n : min(n, d);
        int c = 1;
        while (c <= lim) {
            lim -= c;
            work(c * m[i], c * v[i]);
            c *= 2;
        }
        work(lim * m[i], lim * v[i]);
    }
    int ans = 0;
    for (int i = 0; i <= n * n * n; ++i) {
        if (f[i] > x)
            continue;
        int res = x - f[i];
        int sum = i;
        for (int j = 0; j < n; ++j) {
            int t = a[j] == 0 ? res / m[0] : min(int(res / m[a[j]]), max(0, d - n));
            res -= t * m[a[j]];
            sum += t * v[a[j]];
        }
        cmax(ans, sum);
    }
    cout << ans << "\n";
    return 0;
}