#include <bits/stdc++.h>

using namespace std;

int n, t, ans, prv[1010], cena[1010], a[1010], tmpA[1010];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> t;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
    }
    for(int i = 1; i <= n; ++i){
        cin >> tmpA[i];
        prv[i] = tmpA[i];
    }
    for(int i = 1; i <= n; ++i){
        cin >> cena[i];
    }
    for(int i = 1; i <= n; ++i){
        int t0 = t, tmp = a[i], curr = i;
        while(t0 >= cena[curr]){
            t0 -= cena[curr];
            curr = prv[curr];
            tmp += a[curr];
        }
        ans = max(ans, tmp);
    }
    cout << ans;
    return 0;
}