#include <bits/stdc++.h>
using namespace std;
int P[200005];
int B[200005];
bool vis[200005];
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < (N); ++i) {
    scanf("%d", &P[i]);
    P[i]--;
  }
  for (int i = 0; i < (N); ++i) scanf("%d", &B[i]);
  int C = 0;
  for (int i = 0; i < (N); ++i) {
    if (vis[i]) continue;
    C++;
    for (int j = P[i]; !vis[j]; j = P[j]) {
      vis[j] = true;
    }
  }
  int p = 0;
  for (int i = 0; i < (N); ++i) p ^= B[i];
  assert(C >= 1);
  int ans = C - (C == 1) + (int)(p == 0);
  printf("%d\n", ans);
}
