//%std
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
const int N = 53;
vector<int> G[N];
int n, x, d;
long long c[N], v[N], a[N], dp[N * N * N], id[N], ans;
void dfs (int u) {
	v[u] = 1;
	rep(i, 0, (signed)G[u].size() - 1) {
		dfs (G[u][i]);
		c[u] += c[G[u][i]], v[u] += v[G[u][i]];
	}
} 
void DP(long long x, long long y) { /*debug ("%lld %lld\n", x, y);*/ per(i, 125000, y) dp[i] = min (dp[i], dp[i - y] + x); }
int main ()
{
	scanf ("%d%d%d%lld", &n, &x, &d, &c[1]);
	rep (i, 2, n) { int p; scanf("%lld%d", &c[i], &p); G[p].push_back(i); }
	dfs (1);
	memset (dp, 0x3f, sizeof dp); dp[0] = 0;
	rep (i, 1, n) {
		id[i] = i;
		int lef = i == 1 ? 50 : min (50, d);
		for (int k = 1; k <= lef; lef -= k, k <<= 1) DP (1LL * c[i] * k, 1LL * v[i] * k);
		if (lef) DP (1LL * c[i] * lef, 1LL * v[i] * lef);
	}
	sort (id + 1, id + n + 1, [](int x, int y) { return 1LL * v[x] * c[y] > 1LL * v[y] * c[x]; });
	rep (p, 0, 125000) {
		if(dp[p] > x) break;
		long long tans = p, tx = x - dp[p];
		rep (j, 1, n) { int i = id[j];
			long long cnt = min (1LL * tx / c[i], i == 1 ? 1000000000LL : (max (0LL, d - 50LL)));
			tx -= 1LL * cnt * c[i], tans += 1LL * cnt * v[i];
		}
		ans = max (ans, tans);
	}
	printf ("%lld\n", ans);
	return 0;
}











