#include <bits/stdc++.h>
using namespace std;
int n, p[200001], bl, cnt, cntbl, visited[200001], flag;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
  }
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      int j = i, tmp = j;
      while (!visited[j]) {
        visited[j] = 1;
        j = p[j];
      }
      if (j != tmp) flag = 1;
      cnt++;
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> bl;
    if (bl) cntbl++;
  }
  cout << ((cnt == 1 && !flag ? 0 : cnt) + (cntbl % 2 == 0 ? 1 : 0));
  return 0;
}
