#include <iostream>
#include <algorithm>
#include <vector>


using namespace std;

vector <int64_t> a;
vector <int64_t> x;
vector <int64_t> d;
int64_t m[50000];


main ()

{
    int64_t n;
    cin >> n;

    int64_t t;

    cin >> t;

   a.push_back (-1);

    for (int64_t i=0; i<n; i++)
    {
        int64_t k; cin >> k; a.push_back(k);
    }

 x.push_back (-1);

    for (int64_t i=0; i<n; i++)

    {
        int64_t k; cin >> k; x.push_back(k);
    }

 d.push_back (-1);

    for (int64_t i=0; i<n; i++)
    {
        int64_t k; cin >> k; d.push_back(k);
    }

    for (int64_t i=1; i<=n; i++)
    {
        m[x[i]]=i;
    }


    int64_t mx=0;


    for (int64_t i=1; i<=n; i++)
    {

        int64_t s=0;
        int64_t e=t;

            int64_t o= i;


            s=s+a[o];

            while (e>0)
            {


                if (d[m[o]]>e) break;

                e= e-d[m[o]];



                s=s+a[m[o]];

                o=m[o];

                if (d[m[o]]>e) break;


            }

            if (s>mx) mx=s;

    }

    cout << mx;
}