#include <bits/stdc++.h>
using namespace std;
int p[200010], n, m, k, t, ret;
int vis[200010];
int j = 0;
int main() {
  scanf("%d", &n);
  for (int i(1); i <= (n); ++i) scanf("%d", p + i);
  for (int i(1); i <= (n); ++i) {
    scanf("%d", &k);
    if (k == 1) ++j;
  }
  ret += j % 2 == 0;
  for (int i(1); i <= (n); ++i) {
    if (!vis[i]) ++t;
    int pos = i;
    while (!vis[pos]) {
      vis[pos] = 1;
      pos = p[pos];
    }
  }
  ret += t != 1 ? t : 0;
  printf("%d\n", ret);
  return 0;
}
