#include <bits/stdc++.h>
using namespace std;
int n, a[200005], cnt = 0;
bool vis[200005];
void f(int x) {
  while (!vis[x]) vis[x] = 1, x = a[x];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) {
      ++cnt;
      f(i);
    }
  if (cnt == 1) cnt = 0;
  bool f = 0;
  for (int j, i = 1; i <= n; ++i) scanf("%d", &j), f ^= (j & 1);
  cnt += !f;
  printf("%d\n", cnt);
  return 0;
}
