#include <bits/stdc++.h>
using namespace std;
int n, p[200001], b[200001], colour[200001], c = 0, i, ans = 0, amo1 = 0;
void dfs(int v) {
  colour[v] = 1;
  if (colour[p[v]] == 0) {
    dfs(p[v]);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    colour[i] = 0;
    if (b[i] == 1) {
      amo1++;
    }
  }
  for (i = 1; i <= n; i++) {
    if (colour[i] == 0) {
      dfs(i);
      c++;
    }
  }
  if (c != 1) {
    ans = c;
  } else {
    ans = 0;
  }
  if (amo1 % 2 == 0) {
    ans++;
  }
  cout << ans << endl;
  return 0;
}
