#include <bits/stdc++.h>
using namespace std;
constexpr static int MAXN = 1e6;
int p[MAXN];
bool vis[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
    p[i]--;
  }
  int bsum = 0;
  for (int i = 0; i < n; i++) {
    int b;
    scanf("%d", &b);
    bsum += b;
  }
  int cycles = 0;
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    int j = i;
    while (p[j] != i) {
      vis[j] = true;
      j = p[j];
    }
    vis[j] = true;
    cycles++;
  }
  int total = (cycles == 1 ? 0 : cycles);
  if (bsum % 2 == 0) total++;
  printf("%d\n", total);
}
