#include <bits/stdc++.h>
using namespace std;
int a[200010], b[200010];
bool used[200010];
int main() {
  int n, k = 0, i, x;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) scanf("%d", &b[i]);
  int ans = 1 - accumulate(b + 1, b + n + 1, 0) % 2;
  for (i = 1; i <= n; i++)
    if (!used[i]) {
      used[i] = true;
      x = a[i];
      while (!used[x]) {
        used[x] = true;
        x = a[x];
      }
      k++;
    }
  if (k > 1) ans += k;
  printf("%d\n", ans);
  return 0;
}
