#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;
const int MAXN=60;
int n,V,d;
vector<int> ver[MAXN];
struct node {
	int v,id; ll c;
}a[MAXN];
bool operator < (const node &aa,const node &bb) {
	return aa.v*bb.c>bb.v*aa.c;
}
void dfs(int u) {
	a[u].v=1;
	for(int v:ver[u]) {
		dfs(v);
		a[u].v+=a[v].v;
		a[u].c+=a[v].c;
	}
}
ll f[MAXN*MAXN*MAXN],ans;
int main() {
	scanf("%d%d%d",&n,&V,&d);
	for(int i=1;i<=n;i++) a[i].id=i;
	scanf("%lld",&a[1].c);
	for(int i=2,fa;i<=n;i++) {
		scanf("%lld%d",&a[i].c,&fa);
		ver[fa].push_back(i);
	}
	dfs(1);
	int N=n*n*n,lim=min(n,d);
	memset(f,0x3f,sizeof(f)); f[0]=0;
	for(int i=1;i<=n;i++) {
		int x=lim;
		for(int j=0;(1<<j)<=x;j++) {
			ll c=a[i].c*(1<<j),v=a[i].v*(1<<j);
			for(int k=N;k>=v;k--)
				f[k]=min(f[k],f[k-v]+c);
			x-=1<<j;
		}
		if(x) {
			ll c=a[i].c*x,v=a[i].v*x;
			for(int k=N;k>=v;k--)
				f[k]=min(f[k],f[k-v]+c);
		}
	}
	sort(a+1,a+n+1);
	for(int i=0;i<=N;i++) if(f[i]<=V) {
		ll v=i,c=f[i];
		int j;
		for(j=1;a[j].id!=1;j++) {
			ll x=min((ll)d-lim,(V-c)/a[j].c);
			v+=x*a[j].v,c+=x*a[j].c;
		}
		ll x=(V-c)/a[j].c;
		ans=max(ans,v+x*a[j].v);
	}
	printf("%lld\n",ans);
	return 0;
}