#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
//#define mod 998244353
//#define mod 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;
template <class T>
void chkmax(T &x,T y){
if(x < y) x = y;
}
template <class T>
void chkmin(T &x,T y){
if(x > y) x = y;
}
inline int popcnt(int x){
return __builtin_popcount(x);
}
inline int ctz(int x){
return __builtin_ctz(x);
}
/*ll power(ll p,int k = mod - 2){
ll ans = 1;
while(k){
if(k % 2 == 1) ans = ans * p % mod;
p = p * p % mod;
k /= 2;
}
return ans;
}*/
int T;
int n,s;
int w[5005],cst[5005],a[5005];
int vis[5005];
vector <int> son[5005],sta,cir,_cir;
void init(){
rep(u,1,n) son[u].clear();
sta.clear();
cir.clear();
_cir.clear();
fill(vis,vis + n + 1,0);
int p = s,q;
while(!vis[p]){
sta.eb(p);
vis[p] = 1;
p = a[p];
}
while(1){
q = sta.back();
vis[q] = 2;
sta.pop_back();
cir.eb(q);
if(p == q) break;
}
rep(u,1,n){
if(vis[u] == 2) continue;
son[a[u]].eb(u);
}
}
ll dp[5005][5005];
void dfs(int u){
fill(dp[u],dp[u] + n + 2,0);
for(int v:son[u]){
dfs(v);
ll Mx = -linf;
rep(k,0,n){
chkmax(Mx,dp[v][k]);
dp[u][k] += Mx;
}
}
if(u != s){
rep(k,0,n){
if(k % 2) dp[u][k] += w[u];
dp[u][k] -= 1ll * cst[u] * k;
}
}else{
rep(k,0,n - 1) dp[u][k] = dp[u][k + 1];
rep(k,0,n){
if(k % 2 == 0) dp[u][k] += w[u];
dp[u][k] -= 1ll * cst[u] * k;
}
}
}
ll eval(int p,int k){
if(k < 0 || k > n) return -linf;
return dp[cir[p]][k];
}
void solve(){
scanf("%d%d",&n,&s);
rep(u,1,n) scanf("%d",&w[u]);
rep(u,1,n) scanf("%d",&cst[u]);
rep(u,1,n) scanf("%d",&a[u]);
init();
for(int u:cir) dfs(u);
ll answer = -linf;
if(vis[s] != 2){
answer = max(dp[s][0],dp[s][1]);
printf("%lld\n",answer);
return;
}
int idx = -1;
rep(k,0,SZ(cir) - 1) if(cir[k] == s) idx = k;
rep(k,idx,SZ(cir) - 1) _cir.eb(cir[k]);
rep(k,0,idx - 1) _cir.eb(cir[k]);
cir = _cir;
if(SZ(cir) == 1){
printf("%lld\n",eval(0,0));
return;
}
if(SZ(cir) == 2){
chkmax(answer,eval(0,0) + eval(1,1));
chkmax(answer,eval(0,0) + eval(1,0));
chkmax(answer,eval(0,1) + eval(1,0));
printf("%lld\n",answer);
return;
}
ll v0,v1,v2;
rep(i,0,n){
v0 = eval(0,i) + eval(1,i - 1);
v1 = eval(0,i) + eval(1,i);
v2 = eval(0,i) + eval(1,i + 1);
rep(k,2,SZ(cir) - 1){
chkmax(v2,-linf);
chkmax(v1,v2);
chkmax(v0,v1);
v0 += eval(k,i - 1);
v1 += eval(k,i);
v2 += eval(k,i + 1);
}
chkmax(answer,max(v0,v1));
chkmax(answer,v2);
}
printf("%lld\n",answer);
}
int main(){
// freopen("test.in","r",stdin);
// freopen("test.out","w",stdout);
// scanf("%d",&T);
T = 1;
while(T--) solve();
return 0;
}