// I need some holiday
// But I don't wish that everyday is holiday
// Because I didn't bear the pain
// Because it wasn't a true freedom
//         ——『イヤホンと蝉時雨』·Orangestar

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<LL, LL> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return cur == ed && (ed = (cur = buffer) + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur == ed) ? EOF : *cur++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

inline char *read_str(char *s)
{
	register char ch(getc());
	while(!isgraph(ch)) ch = getc();
	for(; isgraph(ch); ch = getc()) *s++ = ch;
	*s = '\0';
	return s;
}

// END tpl.

const int MAXN = 50;

int n, X, D;

int val[MAXN + 5], fa[MAXN + 5];

vector<int> adj[MAXN + 5];

inline void input()
{
	n = read<int>(), X = read<int>(), D = read<int>();
	for(int i = 1; i <= n; ++i)
	{
		val[i] = read<int>();
		if(i > 1) adj[fa[i] = read<int>()].push_back(i);
	}
}

LL size[MAXN + 5], sum[MAXN + 5];

inline void dfs(int u)
{
	size[u] = 1;
	sum[u] = val[u];
	for(auto v : adj[u])
	{
		dfs(v);
		size[u] += size[v];
		sum[u] += sum[v];
	}
}

inline void solve()
{
	dfs(1);

	int T = min(n, D);

	const LL INF = (LL) 1e18;
	static LL f[MAXN * MAXN * MAXN + 5];

	int S = 0;
	f[0] = 0;
	for(int i = 1; i <= n * n * n; ++i) f[i] = INF;
	for(int i = 1; i <= n; ++i)
	{
		int k = i == 1 ? n : T;
		S += k * size[i];
		for(int r = 1; k >= r; r <<= 1)
		{
			k -= r;

			static LL g[MAXN * MAXN * MAXN + 5];
			for(int j = 0; j <= S; ++j) g[j] = f[j];

			LL v = r * size[i], w = r * sum[i];
			for(int j = 0; j + v <= S; ++j) chkmin(g[j + v], f[j] + w);
			for(int j = 0; j <= S; ++j) f[j] = g[j];
		}

		static LL g[MAXN * MAXN * MAXN + 5];
		for(int j = 0; j <= S; ++j) g[j] = f[j];

		LL v = k * size[i], w = k * sum[i];
		for(int j = 0; j + v <= S; ++j) chkmin(g[j + v], f[j] + w);
		for(int j = 0; j <= S; ++j) f[j] = g[j];
	}

	static pii a[MAXN + 5];
	for(int i = 1; i <= n; ++i) a[i] = MP(size[i], sum[i]);
	sort(a + 1, a + n + 1, [] (pii A, pii B) { return A.snd * B.fst < B.snd * A.fst; });

	LL ans = 0;
	for(int i = 0; i <= S; ++i) if(f[i] <= X)
	{
		LL res = i;
		LL x = X - f[i];
		for(int j = 1; j <= n; ++j)
		{
			LL t = min(a[j].fst == n ? INF : (LL) D - T, x / a[j].snd);
			res += t * a[j].fst;
			x -= t * a[j].snd;
		}
		chkmax(ans, res);
	}
	printf("%lld\n", ans);
}

int main()
{
#ifdef K_ON
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




Measured memory_bytes: 2176