#include <bits/stdc++.h>
int n;
int a[222222], v[222222];
int f, ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  f = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    f ^= x;
  }
  ans = 0;
  for (int i = 1; i <= n; i++)
    if (!v[i]) {
      int cur = i;
      v[cur] = true;
      while (!v[a[cur]]) {
        cur = a[cur];
        v[cur] = true;
      }
      ans++;
    }
  printf("%d\n", (ans == 1 ? 0 : ans) + 1 - f);
  return 0;
}
