#include <iostream>
#include <stdio.h>

using namespace std;

long long mat[10001][10001];
int x[100001],l[100001],d[100001];

int na(long long mat[][10001],int c, long long vreme,int n,int l[],int maxxxx,long long minn){
    if(vreme < minn)
        return maxxxx;
    int i,maxx=0;
    for (i=1;i<=n;i++){
        if ((mat[c][i]!=0) && (vreme >= mat[c][i])){
            if(maxx < na(mat,i,vreme-mat[c][i],n,l,maxxxx,minn) + l[c]){
                maxx = na(mat,i,vreme-mat[c][i],n,l,maxxxx,minn) + l[c];
            }
        }
    }
}

int main()
{
    int n;
    long long t;
    int i,j;
    int maxxx=0,maxx=0,iz=-1;
    long long minn;
    cin >> n >> t;
    for(i=1;i<=n;i++){
        scanf("%d",&l[i]);
        if(l[i] > maxx)
            maxx=l[i];
    }
    for(i=1;i<=n;i++){
        scanf("%d",&x[i]);
    }
    for(i=1;i<=n;i++){
        scanf("%d",&d[i]);
        if (d[i] < minn)
            minn = d[i];
        mat[x[i]][i] = d[i];
    }
    /*for (i=1;i<=n;i++){
        for (j=1;j<=n;j++){
            cout << mat[i][j] << " ";
        }
        cout << endl;
    }*/
    //for (i=1;i<)
    //cout << maxx <<endl;
    //cout <<
    for(i=1;i<=n;i++){
        if (na(mat,i,t,n,l,maxx,minn) > iz)
            iz = na(mat,1,t,n,l,maxx,minn);
    }
    cout << iz;;
    return 0;
}
/*
5 7
7 3 1 4 8
4 3 5 2 1
3 2 4 1 7
*/