#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int cycle = 0, count = 0, input;
  int array[n + 1];
  bool visited[n + 1];
  fill_n(visited, n + 1, false);
  array[0] = 0;
  visited[0] = true;
  for (int i = 1; i <= n; i++) scanf("%d", &array[i]);
  for (int i = 0; i < n; i++) {
    scanf("%d", &input);
    if (input) count++;
  }
  if (count % 2)
    count = 0;
  else
    count = 1;
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      cycle++;
      int start = i;
      while (!visited[start]) {
        visited[start] = true;
        start = array[start];
      }
    }
  }
  if (cycle == 1) cycle = 0;
  printf("%d\n", cycle + count);
}
