#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1000141919
#define MOD 1000000007
inline void chmin(int &x,int v){if(x>v)x=v;}

int N, X, D;
int A[50], C[50];
vector<int> G[50];

void dfs(int x) {
  C[x] = 1;
  for (int t : G[x]) {
    dfs(t);
    C[x] += C[t];
    A[x] = min(A[x]+A[t], INF);
  }
}

const int MAX = 5000;
int dp[2][MAX+1];
int W[30];
void decomp(int a) {
  // w<=2
  rep(k, 30) {
    if (a >= 1<<k) W[k]++, a -= 1<<k;
    else break;
  }
  rep(k, 30) if ((a>>k)&1) W[k]++;
}

int f(int Y) {
  rep(j, MAX+1) dp[0][j] = INF;
  dp[0][0] = 0;
  int m = INF;
  for (int k=29; k>=0; k--) {
    rep(j, MAX+1) dp[1][j] = INF;
    rep(j, MAX+1) if (2*j+((Y>>k)&1) <= MAX) chmin(dp[1][2*j+((Y>>k)&1)], 2*dp[0][j]);
    swap(dp[0], dp[1]);

    rep(i, N) {
      int w = i==0?1:W[k];
      rep(_, w) rep(j, MAX+1) {
        if (j >= C[i]) chmin(dp[0][j-C[i]], dp[0][j]+A[i]);
        else chmin(m, min(0LL+INF, (0LL+dp[0][j]+A[i])<<k));
      }
    }
  }
  m = min(m, dp[0][0]);
  //cout<<"f("<<Y<<")="<<m<<"\n";
  return m;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> X >> D;
  rep(i, N) {
    cin >> A[i];
    if (i != 0) {
      int p; cin >> p; p--;
      G[p].pb(i);
    }
  }
  dfs(0);
  decomp(D);
  //rep(i, N) cout<<C[i]<<"->"<<A[i]<<"\n";

  int lo = 0, hi = 1e9+10;
  while (hi-lo>1) {
    int mid = (lo+hi)/2;
    if (f(mid) <= X) lo = mid;
    else hi = mid;
  }
  cout << lo << "\n";
  return 0;
}
