#include <bits/stdc++.h>
using namespace std;
int per[250000];
bool visited[250000];
void dfs(int s) {
  visited[s] = true;
  if (!visited[per[s]]) dfs(per[s]);
}
int main() {
  int n;
  cin >> n;
  for (long long i = 1; i < n + 1; i++) cin >> per[i];
  bool b[n + 1];
  for (long long i = 1; i < n + 1; i++) cin >> b[i];
  int count = 0, tot = 0;
  memset(visited, false, sizeof(visited));
  for (long long i = 1; i < n + 1; i++) {
    if (!visited[i]) {
      dfs(i);
      count++;
    }
  }
  if (count == 1)
    tot = 0;
  else
    tot = count;
  int c1 = 0;
  for (long long i = 1; i < n + 1; i++) c1 += b[i];
  if (c1 % 2 == 0) tot++;
  cout << tot;
}
