#include<bits/stdc++.h>
using namespace std;
int a[100005], x[100005], d[100005];
vector<pair <int, int> > g[100005];
/*
she said hello
she was letting me know
.... oh how id like to go to paris again
*/
long long dfs(int s, long long t){
    if(t<0) return 0;
    //printf("%d ", s);
    return (long long)a[s]+dfs(g[s][0].first, t-g[s][0].second);
}
int main(){
    int n;
    long long t;
    scanf("%d%I64d", &n, &t);
    for(int i=1; i<=n; ++i) scanf("%d", &a[i]);
    for(int i=1; i<=n; ++i) scanf("%d", &x[i]);
    for(int i=1; i<=n; ++i) scanf("%d", &d[i]);
    for(int i=1; i<=n; ++i) g[i].push_back(make_pair(x[i], d[i]));
    //ajd da iskucam dfs bar za nesto, znam da ovo sto gledam svaki cvor ima degout 1 i da je bespotrebno raditi dfs iz svakog ali nmg da razmisljam sad ughhhh
    long long sol=0;
    for(int i=1; i<=n; ++i){
        long long ss=dfs(i, t);
        //printf("\n");
        if(ss>sol) {
                sol=ss;
                //printf("krece iz %d\n", i);
        }
    }
    printf("%I64d", sol);
    return 0;
}