#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N,X,D;
LL m[55];
int p[55],z[55];
LL w[55],v[55];
LL dp[51*51*51];

int main(){
	cin >> N >> X >> D >> m[0];
	repp(i,1,N){
		cin >> m[i] >> p[i];
		--p[i];
		z[i] = i;
	}
	repm(i,N-1,0){
		w[i] += m[i];
		++v[i];
		w[p[i]] += w[i];
		v[p[i]] += v[i];
	}
	w[0] += m[0];
	++v[0];
	fill(dp,dp+N*N*N+1,X+1);
	dp[0] = 0;
	repp(i,0,N) repp(j,0,i?min(N,D):N) repm(k,N*N*N,-1) dp[v[i]+k] = min(dp[v[i]+k],w[i]+dp[k]);
	sort(z,z+N,[&](const int &a , const int &b){return w[a]*v[b] < w[b]*v[a];});
	int ans = 0;
	repp(i,0,N*N*N+1) if(dp[i] <= X){
		int r = X-dp[i] , n = i;
		repp(j,0,N){
			int m = min(r/w[z[j]],(LL)max(0,z[j]?D-N:X));
			r -= m * w[z[j]];
			n += m * v[z[j]];
		}
		ans = max(ans,n);
	}
	cout << ans << endl;
	return 0;
}
