#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  int ans = 1;
  set<int> u;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    ans ^= x;
    u.insert(i);
    p[i]--;
  }
  int c = 0;
  while (!u.empty()) {
    for (int x = *u.begin(); u.count(x); x = p[x]) u.erase(x);
    c++;
  }
  if (c - 1) ans += c;
  cout << ans;
}
