#include <bits/stdc++.h>

using namespace std;

pair<int,int> niz[500005];
vector<int> g[500005];

int dfs(int n, int t, int s, int tr)
{
    t+=niz[n].second;
    if(t > tr)
    {
        //cout << "S: " << s << endl;
        return s;
    }
    s+=niz[n].first;
    for(auto x : g[n])
       return dfs(x, t, s, tr);

}


int main ()
{
    int n, t;
    cin >> n >> t;
    for(int i=0;i<n;i++)
    {
        cin >> niz[i].first;
    }
    for(int i=0;i<n;i++)
    {
        int pp;
        cin >> pp;
        g[pp-1].push_back(i);
    }
    /*cout << "GRAPH\n";
    for(int i=0;i<n;i++)
    {
        cout << i << " ";
        for(auto x : g[i])
            cout << x << " ";
        cout << endl;
    }
    cout << "-------------------------------\n";*/
    for(int i=0;i<n;i++)
    {
        cin >> niz[i].second;
    }
    int maxi = 0;
    for(int i=0;i<n;i++)
    {
        int p = dfs(i, -niz[i].second, 0, t);
        /*cout << endl;
        cout <<"EE\n";
        cout << p << " " << i << endl;*/
        if(p > maxi)
            maxi = p;
    }
    cout << maxi << endl;
}