#include <bits/stdc++.h>
using namespace std;
long long n;
long long edge[200005], b[200005];
long long seen[200005];
void dfs(long long ind) {
  if (seen[ind]) {
    return;
  }
  seen[ind] = true;
  dfs(edge[ind]);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> edge[i];
  long long res = 0;
  long long bsum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    bsum += b[i];
  }
  res += !(bsum % 2);
  memset(seen, 0, sizeof(seen));
  long long dsets = 0;
  for (int i = 1; i <= n; i++) {
    if (!seen[i]) {
      dfs(i);
      dsets++;
    }
  }
  if (dsets >= 2) {
    res += dsets;
  }
  cout << res << endl;
  return 0;
}
