#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = int(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) begin(x), end(x)
#define dump(x) cerr << #x " = " << x << endl
#define unittest_name_helper(counter) unittest_ ## counter
#define unittest_name(counter) unittest_name_helper(counter)
#define unittest __attribute__((constructor)) void unittest_name(__COUNTER__) ()
using ll = long long;
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
template <typename T> ostream & operator << (ostream & out, vector<T> const & xs) { REP (i, int(xs.size()) - 1) out << xs[i] << ' '; if (not xs.empty()) out << xs.back(); return out; }

ll knapsack(int n, ll max_w, ll d, vector<ll> const & v, vector<ll> const & w) {
    vector<int> order(n);
    iota(ALL(order), 0);
    sort(ALL(order), [&](int i, int j) {
        return v[i] * w[j] > v[j] * w[i];
    });

    vector<int> k(n);
    auto max_k = [&](vector<int>::const_iterator it) {
        int i = *it;
        ll d_i = (i == 0 ? max_w / w[0] : d);
        if (it != order.begin()) {
            int j = *(it - 1);
            if (j == 0 or d - k[j] >= v[i]) {
                return min(d_i, v[j] - 1);
            }
        }
        return d_i;
    };

    ll ans = 0;
    function<void (vector<int>::const_iterator, ll, ll)> go = [&](vector<int>::const_iterator i, ll cur_v, ll cur_w) {
        // base case
        assert (cur_w <= max_w);
        if (i == order.end()) {
            chmax(ans, cur_v);
            return;  // terminate
        }

        {  // linear relaxation
            ll lr_v = cur_v;
            ll lr_w = cur_w;
            auto j = i;
            for (; j != order.end(); ++ j) {  // greedy
                ll k_j = max_k(j);
                if (lr_w + (double)k_j * w[*j] > max_w) break;
                k[*j] = k_j;
                lr_w += k_j * w[*j];
                lr_v += k_j * v[*j];
            }
            if (j != order.end()) {
                ll k_j = (max_w - lr_w) / w[*j];
                assert (k_j < max_k(j));
                lr_w += k_j * w[*j];
                lr_v += k_j * v[*j];
            }
            for (auto j1 = i; j1 != j; ++ j1) {
                k[*j1] = 0;
            }
            chmax(ans, lr_v);
            if (lr_w == max_w or j == order.end()) {
                return;  // accept greedy
            }
            double lr_ans = lr_v + v[*j] * ((max_w - lr_w) /(double) w[*j]);
            if (lr_ans <= ans) return;  // bound
            chmax(ans, lr_v);
        }

        // go to next
        ll max_k_i = min(max_k(i), (max_w - cur_w) / w[*i]);
        ll min_k_i = max(0ll, min(max_k_i, (*i == 0 ? max_w / w[*i] : d) - (n + 3)));
        REP3R (k_i, min_k_i, max_k_i + 1) {
            k[*i] = k_i;
            go(i + 1, cur_v + k_i * v[*i], cur_w + k_i * w[*i]);
        }
        k[*i] = 0;
    };

    try {
        go(order.begin(), 0, 0);
    } catch (int e) {
        // nop
    }
    return ans;
}

ll solve(int n, int x, int d, vector<int> const & m, vector<int> const & parent) {
    // make the adjacent list
    vector<vector<int> > children(n);
    REP3 (i, 1, n) {
        children[parent[i]].push_back(i);
    }

    // fold the tree
    vector<ll> size(n, 1);
    vector<ll> sum_m(ALL(m));
    function<void (int)> go = [&](int i) {
        for (int j : children[i]) {
            go(j);
            size[i] += size[j];
            sum_m[i] += sum_m[j];
        }
    };
    go(0);

    // solve the knapsack problem
    return knapsack(n, x, d, size, sum_m);
}

int main() {
    int n, x, d; cin >> n >> x >> d;
    vector<int> m(n), parent(n);
    cin >> m[0];
    parent[0] = -1;
    REP3 (i, 1, n) {
        cin >> m[i] >> parent[i];
        -- parent[i];
    }
    cout << solve(n, x, d, m, parent) << endl;
    return 0;
}


Measured memory_bytes: 256