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

using namespace std;

int n, t, ans, prv[maxn], vis[maxn], cena[maxn], a[maxn], tmpA[maxn];
int spCena[maxn][maxl], spL[maxn][maxl], spV[maxn][maxl];
int cikC, cikL, toC[maxn], toL[maxn], cBegin;
bool inCycle[maxn];
vector<int> cycle;

int 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;
    return x;
}

void findC(){
    int cur = 1;
    while(true){
        if(vis[cur]){
            int t = cur;
            do {
                cikC += cena[t];
                t = prv[t];
                cikL += a[t];
                cycle.push_back(t);
                inCycle[t] = 1;
            } while(t != cur);
            break;
        } else {
            vis[cur] = 1;
            cur = prv[cur];
        }
    }
    cBegin = cycle.back();
    int curL = 0, curC = cena[cBegin];
    for(auto j : cycle){
        toC[j] = cikC - curC;
        toL[j] = cikL - curL;
        curL += a[j];
        curC += cena[j];
    }
}

int manuelni(int x, int t1){
    int res = 0;
    while(t1 >= cena[x]){
        t1 -= cena[x];
        x = prv[x];
        res += a[x];
    }
    return res;
}

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];
    }
    findC();

    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];
        }
    }
    //cerr << cBegin << ' ';
    for(int i = 1; i <= n; ++i){
        int l = 1, r = 16*n, tmpAns = 0, enV, cenaAns;
        while(l <= r){
            int mid = (l+r)/2;
            int tmpCena, tmpL;
            int tmpV = findAll(i, mid, tmpL, tmpCena);
            if(tmpCena > t){
                r = mid-1;
            } else {
                tmpAns = tmpL;
                cenaAns = tmpCena;
                enV = tmpV;
                //cerr << tmpAns << ' ' << mid << ' ' << i << '\n';
                l = mid+1;
            }
        }
        //cerr << toC[enV] << ' ' << enV << '\n';
        if(inCycle[enV]){
            if(t >= cenaAns + toC[enV]){
                tmpAns += toL[enV]-a[enV];
                if(t - cenaAns - toC[enV] >= cikC and enV != cBegin){
                    tmpAns -= a[cBegin];
                }
                tmpAns += ((t-cenaAns-toC[enV])/cikC)*cikL;
                tmpAns += manuelni(cBegin, (t-cenaAns-toC[enV])%cikC);
            } else {
                tmpAns += manuelni(enV, t-cenaAns);
            }
        }
        //cerr << tmpAns << '\n';
        ans = max(ans, tmpAns);
    }
    cout << ans;
    return 0;
}