#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=55,INF=1e9+1;
int n;
int x,d;
vector <int> son[N];
int a[N],size[N],*b=size,c[N],id[N];
void dfs(int x){
	size[x]=1;
	for (auto y : son[x]){
		dfs(y);
		size[x]+=size[y];
		a[x]=min(a[x]+a[y],INF);
	}
}
const int N3=N*N*N;
int dp[N3];
bool cmp(int i,int j){
	// a[i]/b[i] < a[j]/b[j]
	return (LL)a[i]*b[j]<(LL)a[j]*b[i];
}
int main(){
	n=read(),x=read(),d=read();
	a[1]=read(),c[1]=INF;
	For(i,2,n){
		a[i]=read();
		son[read()].pb(i);
		c[i]=d;
	}
	dfs(1);
	dp[0]=0;
	For(i,1,N3-1)
		dp[i]=INF;
	For(i,1,n){
		int v=min(c[i],50);
		For(j,0,6){
			int t;
			if (v>=(1<<j))
				t=1<<j,v-=t;
			else
				t=v,v=0;
			if ((LL)a[i]*t>=INF)
				continue;
			Fod(k,N3-1,0)
				if (dp[k]<INF)
					dp[k+t*b[i]]=min(dp[k+t*b[i]],dp[k]+a[i]*t);
			if (!v)
				break;
		}
	}
	Fod(i,N3-2,0)
		dp[i]=min(dp[i],dp[i+1]);
	For(i,1,n)
		id[i]=i,c[i]-=min(c[i],50);
	sort(id+1,id+n+1,cmp);
	int ans=-1,p=1;
	int sa=0,sb=0;
	Fod(i,N3-1,0){
		if (dp[i]>x)
			continue;
		int rem=x-dp[i];
		while (p<=n&&rem>=sa+(LL)a[id[p]]*c[id[p]]){
			sa+=a[id[p]]*c[id[p]];
			sb+=b[id[p]]*c[id[p]];
			p++;
		}
		if (p<=n)
			ans=max(ans,i+sb+(rem-sa)/a[id[p]]*b[id[p]]);
		else
			ans=max(ans,i+sb);
	}
	cout<<ans<<endl;
	return 0;
}