#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 100000;
int a[N];
bool u[N];
void dfs(int v) {
  if (!u[v]) {
    u[v] = 1;
    dfs(a[v]);
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i], a[i]--;
  int sum = 1;
  for (int i = 0; i < n; ++i) {
    int b;
    cin >> b;
    sum ^= b;
  }
  int k = 0;
  for (int i = 0; i < n; ++i) {
    if (!u[i]) dfs(i), ++k;
  }
  k = k > 1 ? k : 0;
  cout << sum + k << endl;
}
