#include<cstdio>
#include<cstring>
#define retrun return
#define cpnst const
int N,X,D;
typedef long long ll;
ll V[111111],W[111111],f[111111];
ll dp[133333];
cpnst int lim=131072;
void ins(ll v,ll w)
{
	register int i;
	for(i=lim;i>=w;i--)
		if(dp[i]>dp[i-w]+v)dp[i]=dp[i-w]+v;
}
struct pii
{ll v,w,s;}P[111];
bool operator<(cpnst pii x,cpnst pii y)
{return x.w*y.v>x.v*y.w;}
ll greedy(ll VAG)
{
	register int i;
	ll ret=0;
	for(i=1;i<=N;i++)
	{
		ll K=VAG/P[i].v;
		if(K>P[i].s)K=P[i].s;
		ret+=P[i].w*K,VAG-=P[i].v*K;
	}return ret;
}
void trial(ll v,ll w,int d)
{
	register int i;
	for(i=1;i<=d;d-=i,i<<=1)ins(v*i,w*i);
	if(d)ins(v*d,w*d);
}
#include<algorithm>
int main()
{
	register int i;
	scanf("%d%d%d",&N,&X,&D);
	int DL=D;
	if(N<DL)DL=N;
	scanf("%lld",V+1),W[1]=1;
	for(i=2;i<=N;i++)
		scanf("%lld%lld",V+i,f+i),W[i]=1;
	for(i=N;i>1;i--)
		V[f[i]]+=V[i],W[f[i]]+=W[i];
	for(i=1;i<=N;i++)
		P[i]=(pii){V[i],W[i],D-DL+X*(i==1)};
	std::sort(P+1,P+N+1);
	for(i=1;i<=lim;i++)dp[i]=2e9;
	for(i=1;i<=N;i++)trial(V[i],W[i],DL);
	ll ans=0;
	for(i=0;i<=lim;i++)
	{
		if(dp[i]>X)continue;
		ll T=greedy(X-dp[i])+i;
		if(T>ans)ans=T;
	}printf("%lld\n",ans);
}
/*
Please don't let me down.
*/