#pragma GCC optimize("O3")
#pragma GCC target("tune=native")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
using ll = long long;
using LL = __int128_t;
template <typename Functor>
struct fix_type
{
    Functor functor;
    template <typename... Args>
    decltype(auto) operator()(Args&&... args) const& { return functor(functor, std::forward<Args>(args)...); }
};
template <typename Functor>
fix_type<typename std::decay<Functor>::type> fix(Functor&& functor) { return {std::forward<Functor>(functor)}; }

template <typename T, typename A>
inline ostream& operator<<(ostream& os, const vector<T, A>& v)
{
    os << "[";
    for (const auto& p : v) { os << p << ","; }
    return (os << "]" << endl);
}
template <typename S, typename T>
inline ostream& operator<<(ostream& os, const pair<S, T>& p) { return (os << "<" << p.first << "," << p.second << ">"); }
istream& operator>>(istream& is, LL& v)
{
    string s;
    is >> s;
    v = 0;
    for (int i = 0; i < (int)s.size(); i++) {
        if (isdigit(s[i])) { v = v * 10 + s[i] - '0'; }
    }
    if (s[0] == '-') { v *= -1; }
    return is;
}

ostream& operator<<(ostream& os, const LL& v)
{
    if (v == 0) { return (os << "0"); }
    __int128_t num = v;
    if (v < 0) {
        os << '-';
        num = -num;
    }
    string s;
    for (; num > 0; num /= 10) { s.push_back((char)(num % 10) + '0'); }
    reverse(s.begin(), s.end());
    return (os << s);
}

int main()
{
    int N;
    ll X, D;
    cin >> N >> X >> D;
    vector<ll> m(N);
    cin >> m[0];
    vector<vector<int>> edge(N);
    for (int i = 1; i < N; i++) {
        cin >> m[i];
        int p;
        cin >> p;
        edge[p - 1].push_back(i);
    }
    auto mrec = fix([&](auto&& self, const int s) -> ll {
        ll sum = m[s];
        for (const int to : edge[s]) { sum += self(self, to); }
        return m[s] = sum;
    });
    vector<ll> s(N, 0);
    auto srec = fix([&](auto&& self, const int i) -> ll {
        ll sum = 1;
        for (const int to : edge[i]) { sum += self(self, to); }
        return s[i] = sum;
    });
    mrec(0);
    srec(0);
    using P = pair<LL, LL>;
    vector<P> obj;
    for (int i = 0; i < N; i++) {
        ll num = i == 0 ? X : D;
        ll n = 1;
        for (; (n << 1) - 1 <= num; n <<= 1) { obj.push_back({(LL)1 * m[i] * n, (LL)1 * s[i] * n}); }
        const ll res = num - (n - 1);
        if (res > 0) { obj.push_back({(LL)1 * m[i] * res, (LL)1 * s[i] * res}); }
    }
    auto comp = [](const P& p1, const P& p2) {
        const LL x = (LL)1 * p1.first * p2.second - (LL)1 * p1.second * p2.first;
        return x != 0 ? x < 0 : p1.first > p2.first;
    };
    const int size = obj.size();
    sort(obj.begin(), obj.end(), comp);
    ll ans = 0;
    auto rec = fix([&, size](auto&& self, const int ind, const ll value, const ll rest) {
        if (ind == size) {
            ans = max(ans, value);
            return;
        }
        if (rest >= obj[ind].first) {
            ll greedy = value + obj[ind].second;
            ll res = rest - obj[ind].first;
            for (int i = ind + 1; i < size; i++) {
                if (res > obj[i].first) {
                    greedy += obj[i].second, res -= obj[i].first;
                } else if (res > 0) {
                    greedy += (__int128_t)1 * obj[i].second * res / obj[i].first;
                    break;
                }
            }
            if (greedy > ans) { self(self, ind + 1, value + obj[ind].second, rest - obj[ind].first); }
        }
        self(self, ind + 1, value, rest);
    });
    rec(0, 0, X);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384