#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
const ll MOD=1000000007;
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e15+2;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;

struct rational_t { ll nu, de;
  rational_t(const ll &n = 0, const ll &d = 1) {
    nu = n; de = d;
    //if (de < 0) { nu = -nu; de = -de; }
  }
  /*rational_t operator+(const rational_t& b) const
  { return rational_t( nu*b.de+de*b.nu, de*b.de ); }
  rational_t operator-(const rational_t& b) const
  { return rational_t( nu*b.de-de*b.nu, de*b.de ); }
  rational_t operator-() { return rational_t(-nu, de); }
  rational_t operator*(const rational_t& b) const
  { return rational_t( nu*b.nu, de*b.de ); }
  rational_t operator/(const rational_t& b) const
  { return rational_t( nu*b.de, de*b.nu ); }
  bool operator== (const rational_t & b) const {return nu * b.de == b.nu * de;}
  bool operator== (const ll &k) const { return nu == k * de; }*/
  bool operator< (const rational_t& b) const {
    ll lhs=nu * (ll)b.de,rhs=b.nu * (ll)de;
    return lhs<rhs;
  }
  /*bool operator<= (const rational_t& b) const { return nu * b.de <= b.nu * de; }
  bool operator> (const rational_t& b) const { return nu * b.de > b.nu * de; }
  bool operator>= (const rational_t& b) const { return nu * b.de >= b.nu * de; }*/
};
typedef rational_t rat;

const ll mn=52;
ll a[mn];
vector<ll> g[mn];
ll vsz[mn];
ll vcost[mn];
ll prec(ll x, ll p) {
  ll ans=1;
  for (auto &y:g[x]) {
    if (y==p) continue;
    ans+=prec(y,x);
  }
  return vsz[x]=ans;
}

ll dfs(ll x, ll p) {
  ll cost=a[x];
  for (auto &y:g[x]) {
    if (y==p) continue;
    cost+=dfs(y,x);
  }
  return vcost[x]=cost;
}
vector<pair<rational_t,ll> > vp;
const ll MAXTAKE=(50*50*50);
ll knap[MAXTAKE+1];
int main()
{
  ios_base::sync_with_stdio(false); cin.tie(0);
  fill(knap+1,knap+MAXTAKE+1,INF);
  ll n,total,d; scanf("%lld%lld%lld",&n,&total,&d);
  scanf("%lld",&a[1]);
  for (ll x=2;x<=n;x++) {
    ll p;
    scanf("%lld%lld",&a[x],&p);
    g[x].PB(p); g[p].PB(x);
  }
  prec(1,-1);
  dfs(1,-1);
  for (ll x=1;x<=n;x++) {
    vp.PB(MP(rat(vcost[x],vsz[x]),x));
  }
  sort(vp.begin(),vp.end());
  ll take=min(50LL, d);
  for (ll x=1;x<=n;x++) {
    ll ff=min(d,50LL);
    vector<ll> co;
    for (int j = 0; j < 10; j++) if ((1LL<<j) <= ff) {
      co.PB((1LL<<j));
      ff -= (1LL<<j);
    }
    if (ff > 0) co.PB(ff);
    for (auto &c:co) {
      ll nodes=vsz[x]*c;
      ll cost=vcost[x]*c;
      {
        ll llcost=cost;
        for (ll t=MAXTAKE;t>=nodes;t--) {
          chkmin(knap[t],knap[t-nodes]+llcost);
        }
      }
    }
  }
  for (ll t=MAXTAKE-1;t>=0;t--) chkmin(knap[t],knap[t+1]);
  ll final=0;
  assert(d-take>=0);
  for (ll knapnodes=0;knapnodes<=MAXTAKE;knapnodes++) {
    ll knapcost=knap[knapnodes];
    if (knapcost>total) continue;
    ll pcost=total-knapcost;
    ll pnodes=0;
    for (auto &p:vp) {
      ll cost=p.fst.nu; ll vol=p.fst.de;
      //if(knapnodes==0)prllf("cost:%lld vol:%lld frac:%f\n",cost,vol,cost/(double)vol);
      ll takecnt=pcost/cost;
      if (p.snd!=1) chkmin(takecnt,d-take);
      pcost-=takecnt*cost;
      pnodes+=vol*takecnt;
    }
    ll cand=pnodes+knapnodes;
    chkmax(final,cand);
  }
  printf("%lld\n",final);
}

Measured memory_bytes: 1280