#include <bits/stdc++.h>
using namespace std;
int a[200005], b[200005], c[200005], n, m, i, j, t, s;
void dfs(int x) {
  c[x] = 1;
  if (!c[a[x]]) dfs(a[x]);
}
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (i = 1; i <= n; i++) t += b[i];
  s += !(t & 1);
  t = 0;
  for (i = 1; i <= n; i++) {
    if (!c[i]) {
      dfs(i);
      s++;
      t++;
    }
  }
  if (t == 1) s--;
  cout << s;
  return 0;
}
