#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e7;
bool visited[MAXN];
long long int arr[MAXN];
void dfs(long long int i) {
  visited[i] = true;
  if (visited[arr[i]] == false) {
    dfs(arr[i]);
  }
}
int main() {
  long long int skewers, perm, sum = 0, sres = 0, finalres = 0;
  cin >> skewers;
  for (long long int i = 1; i <= skewers; i++) cin >> arr[i];
  for (long long int i = 1; i <= skewers; i++) {
    cin >> perm;
    sum += perm;
  }
  for (long long int i = 1; i <= skewers; i++) {
    if (visited[i] == 0) {
      sres++;
      dfs(i);
    }
  }
  if (sum % 2 == 0) finalres++;
  if (sres >= 2) finalres += sres;
  cout << finalres << endl;
  return 0;
}
