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

#define Inf ll(1e18)
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=55;
int n,ql,qr;
ll X,D;
ll m[maxn],dp[maxn*maxn*maxn],ndp[maxn*maxn*maxn],qval[maxn*maxn*maxn];
int qpos[maxn*maxn*maxn];
int c[maxn],par[maxn],ord[maxn],lim[maxn];
bool cmp(int a,int b){
	return m[a]*c[b]<m[b]*c[a];
}

int main(){
	scanf("%d%lld%lld",&n,&X,&D);
	REP(i,n){
		scanf("%d",&m[i]);
		if(i>1)scanf("%d",&par[i]);
		c[i]=1;
		ord[i]=i;
	}
	for(int i=n;i>1;i--){
		m[par[i]]+=m[i];
		c[par[i]]+=c[i]; 
	}
	sort(ord+1,ord+1+n,cmp);
	ll summ=0,sumc=0,ans=0;
	REP(i,n){
		if(summ>X)break;
		int s=0;
		REP(j,n)if(j!=i){
			if(ord[j]==1)lim[ord[j]]=n;
			else lim[ord[j]]=min(n,int(D));
			s+=lim[ord[j]]*c[ord[j]];
		}
		rep(k,s+1)dp[k]=Inf; 
		dp[0]=0;
		REP(j,n)if(j!=i){
			rep(k,c[ord[j]]){
				ql=1;qr=0;
				rep(kk,(s-k)/c[ord[j]]+1){
					int now=kk*c[ord[j]]+k;
					while(ql<=qr&&qpos[ql]<kk-lim[ord[j]])ql++;
					if(dp[now]!=Inf){
						while(qr>=ql&&dp[now]-kk*m[ord[j]]<qval[qr])qr--;
						qval[++qr]=dp[now]-kk*m[ord[j]];
						qpos[qr]=kk;
					}
					if(ql<=qr)ndp[now]=qval[ql]+kk*m[ord[j]];
					else ndp[now]=Inf;
				}
			}
			rep(k,s+1)dp[k]=ndp[k];
		}
		rep(k,s+1)if(dp[k]+summ<=X){
			ll cur=ord[i]==1?Inf:D;
			ans=max(ans,k+sumc+min(cur,(X-dp[k]-summ)/m[ord[i]])*c[ord[i]]);
		}
		if(max(D-n,0LL)>Inf/m[ord[i]])break;
		summ+=m[ord[i]]*max(D-n,0LL);
		sumc+=c[ord[i]]*max(D-n,0LL);
	}
	printf("%lld\n",ans);
	return 0;
}