#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6;
int n, p[MAXN], b[MAXN], v[MAXN];
int main() {
  while (scanf("%d", &n) >= 1) {
    int b = 1;
    for (int i = (int)(0); i < (int)(n); i++) {
      scanf("%d", &p[i]);
      p[i]--;
    }
    for (int i = (int)(0); i < (int)(n); i++) {
      int x;
      scanf("%d", &x);
      if (x) b = !b;
    }
    memset(v, 0, sizeof v);
    int ciclos = 0;
    for (int i = (int)(0); i < (int)(n); i++) {
      vector<int> q;
      if (v[i]) continue;
      ciclos++;
      for (int j = i; !v[j]; j = p[j]) v[j] = 1;
    }
    int tot = 0;
    if (ciclos > 1) {
      tot += ciclos;
    }
    tot += b;
    printf("%d\n", tot);
  }
  return 0;
}
