#include<set>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (lc|1)
using namespace std;
inline int read(){
	int x=0; bool f=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=(x<<3)+(x<<1)+(ch^48);
	return f?-x:x;
}
const long long inf=0x3f3f3f3f3f3f3f3f;

int n,x,d;
int m[55],f[55];
long long sz[55],s[55];
int head[55],nx[55],to[55],ec=1;
inline void add(int a,int b){
	nx[++ec]=head[a]; head[a]=ec; to[ec]=b;
}
void dfs(int x){
	sz[x]=1; s[x]=m[x];
	for(int i=head[x];i;i=nx[i]){
		int t=to[i];
		dfs(t); sz[x]+=sz[t]; s[x]+=s[t];
	}
}
struct node{
	int id;
	long long val,co;
	inline bool friend operator < (node a,node b){
		return a.val*b.co>b.val*a.co;
	}
}nd[55];

inline int solve(int v){
	int ret=0;
	for(int i=1;i<=n;++i){
		if(nd[i].co>v) continue;
		int tmp=min((long long)nd[i].id==1?inf:d-min(d,n),v/nd[i].co);
		ret+=tmp*nd[i].val;
		v-=tmp*nd[i].co;
	}
	return ret;
}

long long dp[55*55*55],tmp[55*55*55];
int q[55*55*55],h,t;

int main(){
	n=read(); x=read(); d=read(); m[1]=read();
	for(int i=2;i<=n;++i) m[i]=read(),add(f[i]=read(),i); dfs(1);
	for(int i=1;i<=n;++i) nd[i].id=i,nd[i].val=sz[i],nd[i].co=s[i];
	sort(nd+1,nd+1+n); memset(dp,0x3f,sizeof(dp));
	int tot=n*n*n,lim=min(n,d); dp[0]=0;
	for(int i=1;i<=n;++i){
		long long v=nd[i].val,c=nd[i].co,ttmp=lim;
		if(nd[i].id==1) lim=n;
		for(int u=0;u<v;++u){
			h=1; t=0;
			memcpy(tmp,dp,sizeof(dp));
			for(int j=u;j<=tot;j+=v){
				//printf("%lld %lld %d %d\n",v,c,u,j);
				if(h<=t&&(j-q[h])>lim*v) ++h;
				if(h<=t) tmp[j]=min(tmp[j],dp[q[h]]+c*((j-q[h])/v));
				while(h<=t&&dp[q[t]]-c*(q[t]/v)>=dp[j]-c*(j/v)) --t; q[++t]=j;
			}
			memcpy(dp,tmp,sizeof(dp));
		}
		lim=ttmp;
	}
	int ans=0;
	for(int i=0;i<=tot;++i) if(dp[i]<=x) ans=max(ans,i+solve(x-dp[i]));
	printf("%d\n",ans);
	return 0;
}