#include <bits/stdc++.h>
using namespace std;
const int MAX = 200005;
bool mark[MAX];
int p[MAX];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
    if (!mark[i]) {
      int v = i;
      while (!mark[v]) {
        mark[v] = true;
        v = p[v];
      }
      ans++;
    }
  if (ans == 1) ans--;
  int x = 1;
  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    x ^= val;
  }
  ans += x;
  cout << ans << "\n";
  return 0;
}
