#include <bits/stdc++.h>
using namespace std;
int p[200005];
int b[200005];
int visited[200005];
int cont;
void dfs(int n) {
  cont++;
  visited[n] = true;
  if (!visited[p[n]]) dfs(p[n]);
}
int main() {
  int n;
  cin >> n;
  int i;
  for (i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
  }
  int sum = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    if (b[i]) sum++;
  }
  int len = 0;
  for (i = 1; i <= n; i++) {
    cont = 0;
    if (!visited[i]) {
      dfs(i);
      len++;
    }
  }
  if (len == 1) len = 0;
  if (sum % 2)
    cout << len << endl;
  else
    cout << len + 1 << endl;
  return 0;
}
