#include <bits/stdc++.h>

using namespace std;
#define MAXN 100005
typedef long long ll;
int a[MAXN];
int X[MAXN];
int D[MAXN];
vector <int> g[MAXN];
int scc=0;
bool bio[MAXN];
stack <int> stek;
vector <int> sve[MAXN];

void dfs(int v)
{
    bio[v]=1;
    stek.push(v);
    for(auto x:g[v])
    {
        if(bio[x])
        {
            //ciklus
            while(!stek.empty())
            {
                int y = stek.top();
                stek.pop();
                sve[scc].push_back(y);
                if(y==x){scc++;break;}
            }
        }
        else dfs(x);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    ll t;
    cin >> n >> t;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++)
    {
        cin >> X[i];
        g[X[i]].push_back(i);
    }
    for(int i = 1; i <= n; i++)
    {
        cin >> D[i];
    }
    for(int i = 1; i <= n; i++)
    {
        if(!bio[i])
        {
            dfs(i);
        }
    }
    ll ans = 0;
    for(int i = 0; i < scc; i++)
    {
        ll price = 0;
        ll value = 0;
        for(auto x:sve[i])
        {
            price+=D[i];
            value+=a[i];
        }
        ans=max(ans,(t/price)*value);
    }
    cout << ans;
    return 0;
}