#include <bits/stdc++.h>
#define maxn 100010
#define maxl 40
#define int long long

using namespace std;

int n, t, ans, prv[maxn], cena[maxn], a[maxn], tmpA[maxn];
int spCena[maxn][maxl], spL[maxn][maxl], spV[maxn][maxl], mc = 1e9;

void findAll(int x, int len, int& bt, int& dist){
    bt = 0;
    dist = 0;
    int negb = 0;
    for(int i = 0; i < maxl; ++i){
        if(len & (1LL<<i)){
            bt += spL[x][i];
            dist += spCena[x][i];
            x = spV[x][i];
            negb += a[x];
        }
    }
    negb -= a[x];
    bt -= negb;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> t;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        ans = max(ans, a[i]);
    }
    for(int i = 1; i <= n; ++i){
        cin >> tmpA[i];
        prv[i] = tmpA[i];
    }
    for(int i = 1; i <= n; ++i){
        cin >> cena[i];
        mc = min(cena[i], mc);
    }
    for(int i = 1; i < n+1; ++i){
        spCena[i][0] = cena[i];
        spL[i][0] = a[i] + a[prv[i]];
        spV[i][0] = prv[i];
    }
    for(int i = 1; i < maxl; ++i){
        for(int x = 1; x <= n; ++x){
            int nxt = spV[x][i-1];
            spV[x][i] = spV[nxt][i-1];
            spL[x][i] = spL[x][i-1] + spL[nxt][i-1] - a[nxt];
            spCena[x][i] = spCena[x][i-1] + spCena[nxt][i-1];
        }
    }
    for(int i = 1; i <= n; ++i){
        int l = 1, r = 1e6, tmpAns = 0;
        while(l <= r){
            int mid = (l+r)/2;
            int tmpCena, tmpL;
            findAll(i, mid, tmpL, tmpCena);
            if(tmpCena > t){
                r = mid-1;
            } else {
                tmpAns = tmpL;
                //cerr << tmpAns << ' ' << mid << ' ' << i << '\n';
                l = mid+1;
            }
        }
        ans = max(ans, tmpAns);
    }
    cout << ans;
    return 0;
}