#include <bits/stdc++.h>
using lint = long long int;
using pii = std::pair<int, int>;
using std::vector;
int ve[200100];
bool check[200100];
int main(void) {
  int N, hol = 0;
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    int temp;
    scanf("%d", &temp);
    ve[i] = temp;
  }
  for (int i = 1; i <= N; i++) {
    int temp;
    scanf("%d", &temp);
    hol += temp;
  }
  int cou = 0;
  for (int i = 1; i <= N; i++) {
    if (!check[i]) {
      int ind = i;
      cou++;
      while (!check[ind]) {
        check[ind] = true;
        ind = ve[ind];
      }
    }
  }
  int ans = 1 - (hol % 2);
  if (cou != 1) {
    ans += cou;
  }
  printf("%d", ans);
  return 0;
}
