#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> p(n), b(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &p[i]);
    --p[i];
  }
  int s = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &b[i]);
    s += b[i];
  }
  int cnt = 0;
  vector<int> was(n);
  for (int i = 0; i < n; ++i)
    if (!was[i]) {
      ++cnt;
      int cur = i;
      while (!was[cur]) {
        was[cur] = 1;
        cur = p[cur];
      }
    }
  int res = 1 - s % 2;
  if (cnt > 1) res += cnt;
  printf("%d\n", res);
  return 0;
}
