#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int p[n];
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
    --p[i];
  }
  int b[n];
  for (int i = 0; i < n; ++i) cin >> b[i];
  int ct1 = count(b, b + n, 1), ct2 = 0;
  vector<bool> vis(n, false);
  for (int i = 0; i < n; ++i) {
    if (!vis[i]) {
      ++ct2;
      vis[p[i]] = true;
      int t = p[i];
      while (t != i) {
        vis[t] = true;
        t = p[t];
      }
    }
  }
  cout << ((ct1 & 1) == 0) + (ct2 == 1 ? 0 : ct2) << endl;
  return 0;
}
