#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll N = 55, inf = 1e9;
typedef long long ll;
ll n,X,D,m[N],fa[N];
ll sum[N], size[N], f[N * N * N];
struct item{
	ll cost, value, gs, gs1;
	bool operator < (const item b) const {
		return (double)value / cost > (double)b.value / b.cost;
	}
} is[N];
ll min(ll a,ll b) {
	return a > b ? b : a;
}
ll max(ll a,ll b) {
	return a > b ? a : b;
}

ll Q[N * N * N], h, t, v[N * N * N];
ll gre(ll a) {
	if (a <= 0) return 0;
	ll ret = 0;
	for (ll i = 1; i <= n; i++) {
		ll gs = min(a / is[i].cost, is[i].gs);
		ret += gs * is[i].value;
		a -= gs * is[i].cost;
	}
	return ret;
}

int main() {
	cin>>n>>X>>D;
	scanf("%lld\n",&m[1]);
	for (ll i = 2; i <= n; i++) 
		scanf("%lld %lld\n",&m[i],&fa[i]);
	for (ll i = n; i>1; i--) {
		sum[i] += m[i], size[i] ++;
		sum[fa[i]] += sum[i];
		size[fa[i]] += size[i];
	}
	
	sum[1]+=m[1],size[1]++;
	for (ll i = 1; i <= n; i++) {
		is[i] = (item) {sum[i], size[i], i == 1 ? inf : D, 0};
	}

	sort(is + 1, is + 1 + n);
	memset(f, 127/3 ,sizeof f); f[0] = 0;
	
	ll n2 = n * n * n;
	for (ll i = 1; i <= n; i++) {
		is[i].gs1 = min(is[i].gs, n);
		for (ll y = 0; y < is[i].value; y++) {
			t = 0, h = 1;
			for (ll j = y; j <= n2; j += is[i].value) {
				while (h <= t && Q[h] < j - is[i].gs1 * is[i].value) h++;
				ll tf = 1e18;
				if (h <= t) {
					tf = v[h] + j / is[i].value * is[i].cost;
				}
				ll vv = f[j] - j / is[i].value * is[i].cost;
				while (h <= t && v[t] >= vv) t--;
				Q[++t] = j, v[t] = vv;
				
				f[j] = min(f[j], tf);
			}
		}
		is[i].gs -= is[i].gs1;
	};
 	ll ans = 0;
	for (ll i = 0; i <= n2; i++) {
		if (f[i] <= X)
			ans = max(ans, i + gre(X - f[i]));
	}
	cout<<ans<<endl;
}