#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define f first
#define s second

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> drvo; ///find_by_order()  order_of_key()
const int N=1e5+5,L=20;
pair<int,pair<ll,ll> > up[N][L];
int main()
{
    int n;
    ll t;
    scanf("%i %lld",&n,&t);
    vector<int> a(n),x(n),d(n);
    for(int i=0;i<n;i++)
        scanf("%i",&a[i]);
    for(int i=0;i<n;i++)
        scanf("%i",&x[i]),x[i]--;
    for(int i=0;i<n;i++)
        scanf("%i",&d[i]);
    for(int i=0;i<n;i++){
        up[i][0]={x[i],{d[i],a[x[i]]}};
        //printf("up[%i][%i]: %i,%i,%i\n",i,0,x[i],d[i],a[x[i]]);
    }
    for(int j=1;j<L;j++)
        for(int i=0;i<n;i++){
            up[i][j]={up[up[i][j-1].f][j-1].f,{up[up[i][j-1].f][j-1].s.f+up[i][j-1].s.f,up[up[i][j-1].f][j-1].s.s+up[i][j-1].s.s}};
            //printf("up[%i][%i]: %i,%lld,%lld\n",i,j,up[i][j].f,up[i][j].s.f,up[i][j].s.s);
        }
    ll best=0;
    for(int i=0;i<n;i++)
    {
        ll tr=t;
        int ttr=i;
        ll cost=a[i];
        for(int j=L-1;j>=0;j--)
        {
            if(up[ttr][j].s.f<=tr)
            {
                tr-=up[ttr][j].s.f;
                cost+=up[ttr][j].s.s;
                ttr=up[ttr][j].f;
            }
        }
        best=max(best,cost);
    }
    printf("%lld\n",best);
    return 0;
}