#include <bits/stdc++.h>
#define X first
#define Y second
#define LL long long
#define MP make_pair
#define PB push_back
#define SZ(a) (LL)(a.size())
const LL INF = 1000 * 1000 * 1000 + 47;
const LL LINF = INF * (LL)INF;
using namespace std;
const int MAXN = 55;
int idx[MAXN];
int N , x , D;
int m[MAXN];
int p[MAXN];
LL X[MAXN] , Y[MAXN] , Z[MAXN];
int am[MAXN][6];
LL dp[2][MAXN * MAXN * MAXN];
bool cmp(int i1 , int i2)
{
	return Y[i1] * X[i2] > Y[i2] * X[i1];
}
void getAm(int j)
{
	LL ye = min(Z[j] , 50LL);
	for(int i = 0; i < 5; i++)
	{
		if(ye >= (1 << i))
		{
			am[j][i] = (1 << i);
			ye -= am[j][i];
		}
	}
	am[j][5] = ye;
}
int main() 
{
	ios_base::sync_with_stdio(0);
	cin >> N >> x >> D;
	Z[0] = LINF;
	for(int i = 1; i < N; i++)
		Z[i] = D;
	for(int i = 0; i < N; i++)
		getAm(i);
	
	
	for(int i = 0; i < N; i++)
	{
		cin >> m[i];
		if(i)
			cin >> p[i];
		p[i]--;
	}
	for(int i = N - 1; i >= 0; i--)
	{
		Y[i]++;
		X[i] += m[i];
		if(i)
		{
			Y[p[i]] += Y[i];
			X[p[i]] += X[i];
		}
		//cout << i << " " << X[i] << " " << Y[i] << " " << Y[i] * 1.0 / X[i] << endl;
	}
	for(int i = 0; i < N; i++)
		idx[i] = i;
	sort(idx , idx + N , cmp);
	
	int cur = 0;
	for(int i = 0; i < 2; i++)
		for(int YY = 0; YY <= 50 * 50 * 50; YY++)
			dp[i][YY] = LINF;
	dp[0][0] = 0;
	for(int item = 0; item < N; item++)
		for(int type = 0; type < 6; type++)
		{
			for(int YY = 0; YY <= 50 * 50 * 50; YY++)
			{
				dp[cur ^ 1][YY] = min(dp[cur ^ 1][YY] , dp[cur][YY]);
				dp[cur ^ 1][YY + Y[item] * am[item][type]] = min(dp[cur ^ 1][YY + Y[item] * am[item][type]]
				 , dp[cur][YY] + X[item] * am[item][type]);
			}
			cur ^= 1;
		}
	LL ans = 0;
	for(int YY = 0; YY <= 50 * 50 * 50; YY++)
	{
		LL w = dp[cur][YY];
		//cout << YY << " " << w << endl;
		if(w > x)
			continue;
		LL she = x - w;
		LL curAns = YY;
		for(int item = 0; item < N; item++)
		{
			LL lft = max(0LL , Z[idx[item]] - 50LL);
			
			LL XX = X[idx[item]] , y = Y[idx[item]];
			LL took = min(lft , she / XX);
			she -= took * XX;
			curAns += took * y;
		}
		ans = max(ans , curAns);
	}
	cout << ans;
	
}
