#include<cstdio>
#include<algorithm>
#include<cstring>
#define fo(x,a,b) for(int x=(a),_e=(b);x<=_e;x++)
#define fd(x,a,b) for(int x=(a),_e=(b);x>=_e;x--)
using namespace std;
typedef long long ll;
const int N=55;
ll f[N*N*N],W[N*N],V[N*N],val[N],w[N],ans=0;
int fa[N],id[N],n,x,D,lim,top=0,tot=0;
bool cmp(int x,int y){
	return val[x]*w[y]>val[y]*w[x];
}
int main(){
	scanf("%d %d %d",&n,&x,&D);
	scanf("%lld",&w[1]);val[1]=1;
	fo(i,2,n) scanf("%lld %d",&w[i],&fa[i]);	
	fd(i,n,2) val[i]++,val[fa[i]]+=val[i],w[fa[i]]+=w[i];
	lim=min(n,D);
	fo(i,1,n) top+=val[i]*lim,id[i]=i;
//	fo(i,1,n) printf("val:%lld w:%lld\n",val[i],w[i]);
	sort(id+1,id+n+1,cmp);
	
	fo(i,1,n) {
		ll dw=w[i],dv=val[i];int l=1,now=lim;
		while(now>=l) {
			W[++tot]=dw;V[tot]=dv;
			now-=l;
			dw=dw<<1,dv=dv<<1,l=l<<1;
		}
		if(now) W[++tot]=w[i]*now,V[tot]=val[i]*now;
	}

	memset(f,0x3f,sizeof(f));f[0]=0;
	fo(i,1,tot) {
		fd(j,top-V[i],0) f[j+V[i]]=min(f[j+V[i]],f[j]+W[i]);
	}

	fo(i,0,top) {
//		printf("i:%d f:%lld\n",i,f[i]);
		if(f[i]>x) continue;
		ll res=x-f[i],got=i,cs;
		fo(j,1,n) {
			cs=res/w[id[j]];
			if(id[j]>1) cs=min(cs,1ll*max(D-n,0));
			got+=cs*val[id[j]];
			res-=cs*w[id[j]];
//			printf("v:%lld w:%lld cs:%lld res:%lld\n",val[id[j]],w[id[j]],cs,res);
			if(!res) break;
		}
//		printf("%lld\n",got);
		ans=max(ans,got);
	}
	printf("%lld",ans);
	return 0;
}
