#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const double EPS = 1e-9;
const long long MOD = (long long)(1e9 + 7);
const long long MAXV = (long long)(2e5 + 10);
const long long MAXE = (long long)(1e6 + 10);
int V;
int G[MAXV];
int H[MAXV];
int c;
bool mark[MAXV];
int dfs(int u) {
  int v, w = 0;
  v = G[u];
  if (!mark[v]) {
    mark[v] = true;
    w = dfs(v);
  }
  return H[u] + w;
}
int main() {
  scanf("%d", &V);
  for (int i = 1; i <= V; i++) {
    scanf("%d", &G[i]);
  }
  for (int i = 1; i <= V; i++) {
    scanf("%d", &H[i]);
    c += H[i];
  }
  int aux;
  int sol = 0;
  int cc = 0;
  for (int i = 1; i <= V; i++) {
    if (!mark[i]) {
      cc++;
      mark[i] = true;
      aux = dfs(i);
    }
  }
  if (cc == 1)
    sol = 0;
  else
    sol = cc;
  if (c % 2 == 0) sol++;
  printf("%d\n", sol);
  return 0;
}
