#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
#define forn(a,b,c) for(int a=b;a<=c;a++)
#define ford(a,b,c) for(int a=b;a>=c;a--)
const int N=1e3+5;const int T=1e3+5;
vector<pii>g[N];
int p[N],v[N],n,t,w[N],c[N];
int dp[N][N];
int calc(int i,int time){
    if(time<0)return 0;
    if(dp[i][time]!=-1){
        return dp[i][time];
    }
    int start=v[i],mxNext=0;
    for(auto&y:g[i]){
        int nxTime=time-y.s;
        int nxDp=calc(y.f,nxTime);
        mxNext=max(mxNext,nxDp);
    }
    dp[i][time]=start+mxNext;
    return dp[i][time];
}
int main()
{
    scanf("%d%d",&n,&t);
    forn(i,1,n){
        scanf("%d",&v[i]);
    }
    forn(i,1,n){
        scanf("%d",&p[i]);
    }
    forn(i,1,n){
        scanf("%d",&w[i]);
        g[p[i]].pb({i,w[i]});
    }
    forn(i,1,n){
        forn(j,0,t){
            dp[i][j]=-1;
        }
    }
    int mx=0;
    forn(i,1,n){
        c[i]=calc(i,t);
        mx=max(mx,c[i]);
    }
    printf("%d\n",mx);
    return 0;
}
/*
6 200
1 1 1 1 1 100
3 1 2 5 4 5
1 1 1 10 10 1
*/