#include <bits/stdc++.h>
using namespace std;
bool visited[200005] = {0};
int tab[200005];
void dfs(int i, int j) {
  visited[j] = 1;
  if (tab[j] != i) dfs(i, tab[j]);
}
int main() {
  int n, a, k = 0;
  int ok = 1;
  cin >> n;
  for (int i = 1; i < n + 1; i++) cin >> tab[i];
  for (int i = 1; i < n + 1; i++) {
    cin >> a;
    if (a == 1) ok++;
  }
  for (int i = 1; i < n + 1; i++) {
    if (!visited[i]) {
      k++;
      dfs(i, i);
    }
  }
  k--;
  if (k) k++;
  if (ok % 2) k++;
  cout << k;
}
