#include<bits/stdc++.h>
using namespace std;using ll=long long;const int M=998244353;const double eps=1e-10;const ll inf=1e17;
struct S
{
vector<int>fa,cov,ring;vector<ll>w,c;vector<vector<int>>es;int n,S,rlen;
vector<vector<ll>>dres;vector<vector<vector<ll>>>dp;//ring_pos/lay_cnt/drop_cnt
void ini(){fa.resize(n+1);w.resize(n+1);c.resize(n+1);es.resize(n+1);
cov.resize(n+1,0);dres.resize(n+1,vector<ll>(n+1));}
void findring(){
int x;for(x=S;!cov[x];cov[x]=1,x=fa[x],ring.push_back(x));
if(x!=S)ring.clear(),ring.push_back(S);reverse(ring.begin(),ring.end());
cov.assign(n+1,0);for(auto k:ring)cov[k]=1;rlen=ring.size();}
void spr(int x){
for(int i=0;i<=n;i++)dres[x][i]=w[x]*(i&1)-c[x]*i;for(auto k:es[x])if(!cov[k])
{cov[k]=1,spr(k);ll mx=0;for(int i=0;i<=n;i++)mx=max(mx,dres[k][i]),dres[x][i]+=mx; }}
void solve()
{
cin>>n>>S;ini();for(int i=1;i<=n;i++)cin>>w[i];for(int i=1;i<=n;i++)cin>>c[i];
for(int i=1;i<=n;i++)cin>>fa[i],es[fa[i]].push_back(i);findring();for(auto k:ring)spr(k);
dp.resize(2,vector<vector<ll>>(n+1,vector<ll>(3,-inf)));
for(int i=0,sw=((rlen-1)&1);i<=n;i++)dp[sw][i][0]=dres[ring.back()][i];
for(int i=rlen-2,sw=(i&1);i>=0;i--,sw^=1,dp[sw].assign(n+1,vector<ll>(3,-inf)))for(int a=0;a<=n;a++)
{for(int b=a;b>=max(0,a-2);b--)for(int c=b;c>=max(0,a-2);c--)dp[sw][a][a-c]=max(dp[sw][a][a-c],dp[sw^1][b][b-c]);
for(int e=0;e<3;e++)dp[sw][a][e]+=dres[ring[i]][a];}
ll res=-inf;if(rlen==1)res=max(dp[0][1][0],dp[0][2][0]);
else if(rlen==2)res=max(dp[0][2][2],max(dp[0][1][0],dp[0][1][1]));
else for(int i=1;i<=n;i++)for(int e=0;e<3;e++)res=max(res,dp[0][i][e]);cout<<res+c[S]<<"\n";
}
};
int main(){ios::sync_with_stdio(0);cin.tie(0);precal();int t=1;/*cin>>t;*/while(t--){S SS;SS.solve();}}