#include<bits/stdc++.h>
#define ll long long
#define pb emplace_back
#define N 53
#define INF 1000000000
using namespace std;
vector<int> e[N];
struct Info{ll nu,si,co;}a[N];
ll sp[N],p[N],n,m,x,d,si[N],dp[N*N*N],st[N*N*N],na,nd[N*N*N],ans;
void dfs(int x){
	sp[x]=p[x];si[x]=1;
	for (auto y:e[x]){dfs(y);si[x]+=si[y];sp[x]+=sp[y];}
}
void add(ll x,ll y,ll z){
	for (int i=0;i<y;i++){
		int l=1,r=0;
		for (int j=i;j<=n*n*n;j+=y){
			if (st[l]+x*y<j) l++;
			if (l<=r)nd[j]=min(dp[st[l]]+z*((j-st[l])/y),dp[j]);else nd[j]=m+1;
			while (r>=l&&dp[j]<dp[st[r]]+((j-st[r])/y)*z)r--;
			st[++r]=j;
		}
	}
	for (int i=0;i<=n*n*n;i++)dp[i]=min(dp[i],nd[i]);
}
bool c1(const Info &a,const Info &b){return a.co*b.si<b.co*a.si;}
int main(){
	cin>>n>>m>>d;
	for (int i=1;i<=n;i++){cin>>p[i];if (i!=1){cin>>x;e[x].pb(i);}}
	dfs(1);
	dp[0]=0;for (int i=1;i<=n*n*n;i++)dp[i]=m+1;
	for (int i=1;i<=n;i++){
		if (i==1){add(n,si[i],sp[i]);a[++na]=(Info){INF,si[i],sp[i]};}
		else{add(min(n,d),si[i],sp[i]);a[++na]=(Info){max(0ll,d-n),si[i],sp[i]};}
	}
	sort(a+1,a+na+1,c1);
	for (int i=0;i<=n*n*n;i++){
		ll su=i,ne=dp[i];
		if (ne<=m){
			for (int j=1;j<=n;j++){
				if (a[j].nu<=(m-ne)/a[j].co){ne+=a[j].nu*a[j].co;su+=a[j].si*a[j].nu;}
				else{su+=a[j].si*((m-ne)/a[j].co);break;}
			}
			ans=max(ans,su);
		}
	}
	cout<<ans<<endl;
	return 0;
}