#include <bits/stdc++.h>
using namespace std;
bool visited[1 << 18];
int* p;
void dfs(int s) {
  if (visited[s]) return;
  visited[s] = true;
  dfs(p[s]);
  return;
}
int main() {
  int n, t;
  scanf("%d", &n);
  p = new int[n];
  int b = 1, cnt = -1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &t);
    p[i] = t - 1;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &t);
    b ^= t;
  }
  for (int i = 0; i < n; i++)
    if (!visited[i]) {
      cnt++;
      dfs(i);
    }
  if (cnt == 0)
    cout << b;
  else
    cout << cnt + 1 + b;
  return 0;
}
