#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int N;
ll T, ans = 0;
int ocene[1000005], x[1000005], d[1000005];

void lepota(int n, ll t){
    ans += ocene[n];
    //cout << "ans=" << ans;
    if(x[n] == -1) return;
    if(t - d[x[n]] >= 0) {
        //cout << "n=" << n << " t=" << t;
        lepota(x[n], t - d[x[n]]);
    }
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin >> N >> T;
    int temp, j = 1;
    memset(x, -1, sizeof x);
    for(int i = 1; i <= N; i++){
        cin >> ocene[i];
    }
    for(int i = 1; i <= N; i++){
        cin >> temp;
        x[temp] = j++;
    }
    for(int i = 1; i <= N; i++){
        cin >> d[i];
    }
    int maxx = 0;
    for(int i = 1; i <= N; i++){
        ans = 0;
        lepota(i, T);
        if(maxx < ans){
            maxx = ans;
        }
    }
    cout << maxx;
    return 0;
}