#include <bits/stdc++.h>
using namespace std;

#define int long long
const int N = 55;
const int INF = 1e15 + 123;

void minimize(int &x, int y) {
	x = (x > y) ? y : x;
}

int n, X, D;
vector <int> g[N];
int s[N], c[N];
int dp[N][N * N * N];
int lim1[N], lim2[N];

// precalculate
void dfs(int u) {
	c[u] = 1;
 	for (int &v : g[u]) {
		dfs(v);
		c[u] += c[v];
		s[u] += s[v];
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> X >> D;
	cin >> s[1];
	for (int i = 2; i <= n; ++i) {
		int p; cin >> s[i] >> p;
		g[p].push_back(i);	
	}

	dfs(1);
	
	// dp
	for (int i = 1; i <= n; ++i) {
		int lim = INF;
		if (i > 1) lim = D;
		lim1[i] = min(lim, 50LL);
		lim2[i] = lim - lim1[i];
	}

	// cost s[i], gain c[i]

	// bag1: knapsack (total gain <= N^3)
	// dp[i][total] = min weight
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j < N * N * N; ++j) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < N * N * N; ++j) {
			int mx = min(lim1[i], j / c[i]);
			for (int take = 0; take <= mx; ++take) {
				minimize(dp[i][j], dp[i - 1][j - take * c[i]] + take * s[i]);
			} 
		}
	}

	// greedily choose items in bag 2
	vector <int> p;
	for (int i = 1; i <= n; ++i) p.push_back(i);
	sort(p.begin(), p.end(), [&](int x, int y){
		return 1LL * c[x] * s[y] > 1LL * c[y] * s[x];
		// c[x] / s[x] > c[y] / s[y]
	});


	int res = 0;
	for (int j = 0; j < N * N * N; ++j) {
		int rem = X - dp[n][j];
		int tot = j;
		if (rem < 0) continue;
		for (int &i : p) {
			int take = min(lim2[i], rem / s[i]);
			tot += c[i] * take;
			rem -= s[i] * take;
		}
		res = max(res, tot);
	}

	cout << res << '\n';
}
