#include <bits/stdc++.h>
using namespace std;
int check[200002] = {0};
int main() {
  int n;
  scanf("%d", &n);
  vector<int> permu;
  int num_of_1 = 0;
  for (int i = 0; i < n; i++) {
    int temp;
    scanf("%d", &temp);
    permu.push_back(temp - 1);
  }
  for (int i = 0; i < n; i++) {
    int temp;
    scanf("%d", &temp);
    if (temp == 1) {
      num_of_1++;
    }
  }
  int ans = 0;
  if ((num_of_1 % 2) == 0) {
    ans++;
  }
  int num_of_cycle = 0;
  for (int i = 0; i < n; i++) {
    if (check[i] == 1) {
      continue;
    }
    int temp = i;
    int temp2;
    do {
      check[temp] = 1;
      temp2 = temp;
      temp = permu[temp2];
    } while (temp != i);
    num_of_cycle++;
  }
  if (num_of_cycle != 1) {
    ans += (num_of_cycle);
  }
  printf("%d", ans);
}
