#include <bits/stdc++.h>
using namespace std;
const int MAX_n = 200000;
int p[MAX_n], b[MAX_n];
bool visited[MAX_n];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", p + i);
  for (int i = 0; i < n; ++i) scanf("%d", b + i);
  int cnt = 0, flip = 0;
  memset(visited, false, sizeof(visited));
  for (int i = 0; i < n; ++i) {
    flip ^= b[i];
    if (visited[i]) continue;
    ++cnt;
    int crt = i;
    while (!visited[crt]) {
      visited[crt] = true;
      crt = p[crt] - 1;
    }
  }
  int ans = (cnt == 1 ? 0 : cnt) + (flip ^ 1);
  printf("%d\n", ans);
}
