#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
struct thing
{
	long long w;int v,id;
	friend bool operator < (thing a,thing b){return a.w*b.v==a.v*b.w?a.v>b.v:a.w*b.v<a.v*b.w;}
}p[51];
int n,x,d,m[51],f[51],siz[51],used[51],ans;
long long sum[51];
vector<int>E[51];
void dfs(int v)
{
	siz[v]=1,sum[v]=m[v];
	for(auto u:E[v])
	{
		dfs(u);
		sum[v]+=sum[u];
		siz[v]+=siz[u];
	}
	p[v]=thing{sum[v],siz[v],v};
}
long long dp[125010],q[125010][2],h,t;
int main()
{
	scanf("%d %d %d %d",&n,&x,&d,&m[1]);
	for(int i=2;i<=n;++i)scanf("%d %d",&m[i],&f[i]),E[f[i]].push_back(i);
	dfs(1);
	sort(p+1,p+1+n);
	int sum=0;
	for(int i=1;i<=n;++i)sum+=p[i].v*min(n,p[i].id==1?0x3f3f3f3f:d);
	dp[0]=0;
	memset(dp+1,0x3f,sum<<3);
	for(int i=1;i<=n;++i)
	{
		int num=min(n,p[i].id==1?0x3f3f3f3f:d);
		for(int j=0;j<p[i].v;++j)
		{
			h=1,t=0;
			for(int k=j,c=0;k<=sum;k+=p[i].v,++c)
			{
				long long va=dp[k]-c*p[i].w;
				while(h<=t&&q[t][0]>va)--t;
				q[++t][0]=va,q[t][1]=c;
				while(h<=t&&q[h][1]+num<c)++h;
				dp[k]=q[h][0]+c*p[i].w;
			}
		}
	}
	for(int i=0;i<=sum;++i)
	{
		if(x<dp[i])continue;
		int rem=x-dp[i];
		int cur=i;
		for(int j=1;j<=n;++j)
		{
			int now=p[j].id==1?0x3f3f3f3f:max(d-n,0);
			now=min(now,(int)(rem/p[j].w));
			cur+=now*p[j].v;
			rem-=now*p[j].w;
		}
		ans=max(ans,cur);
	}
	printf("%d",ans);
	return 0;
}
