#include<bits/stdc++.h>

using namespace std;

#define llng long long

//#define DEBUG

llng O[10001],X[10001],D[10001];
llng n,t;


llng obilazakdo(llng poc)      //poc je krajnji cvor, odnosno pocetak vracanja unazad
{
    llng TD[10001],TO[10001];

    llng pct=0LL, pco=0LL;  // T i O pre ciklusa
    llng ckt=0LL, cko=0LL;  // T i O u ciklusu

    for (llng i=1LL;i<=n;i++)
    {
        TD[i]=-1LL;
        TO[i]=-1LL;
    }

    llng tri=poc,trt=0LL,tro=O[poc];

    #ifdef DEBUG
    cout << " >>> OBILAZAK DO " << poc << endl;
    cout << " | i\t | t\t | o\t | " << endl;
    cout << " |  \t |  \t |  \t | " << endl;
    cout << " | " << tri << "\t | " << trt << "\t | " << tro << "\t | " << endl;
    #endif // DEBUG


    while (trt+D[tri]<=t && TD[tri]==-1LL)
    {
        TD[tri]=trt;
        TO[tri]=tro;
        trt+=D[tri];
        tri=X[tri];
        tro+=O[tri];
        #ifdef DEBUG
        cout << " | " << tri << "\t | " << trt << "\t | " << tro << "\t | " << endl;
        #endif // DEBUG
    }

    pct=TD[tri];
    pco=TO[tri];

    ckt=trt-pct;
    cko=tro-pco;

    llng k=(t-pct)/ckt;

    // OVO ZA SAD DOBRO RADI (SVE IZNAD)

    trt=pct+k*ckt;
    tro=pco+k*cko;

    while (trt+D[tri]<=t)
    {
        trt+=D[tri];
        tri=X[tri];
        tro+=O[tri];
    }

    #ifdef DEBUG
    cout << " NASLI CIKLUS " << endl;
    cout << " PCT = " << pct << endl;
    cout << " PCO = " << pco << endl;
    cout << " CKT = " << ckt << endl;
    cout << " CKO = " << cko << endl;
    cout << " K   = " << k << endl;
    cout << " TRT = " << trt << endl;
    cout << " TRO = " << tro << endl;
    #endif // DEBUG





    return tro;
}


int main()
{

    cin >> n >> t;


    for (llng i=1LL;i<=n;i++)
    {
        cin >> O[i];
    }

    for (llng i=1LL;i<=n;i++)
    {
        cin >> X[i];
    }

    for (llng i=1LL;i<=n;i++)
    {
        cin >> D[i];
    }

    llng res=0;

    for (llng i=1LL;i<=n;i++)
    {
        llng tres=obilazakdo(i);
        #ifdef DEBUG
        cout << "-";
        #endif // DEBUG

        if (tres>res) res=tres;
    }

    cout << res;

    return 0;
}