#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> P, B;
int solve() {
  if (N == 1) return B[1] == 0 ? 1 : 0;
  vector<int> seen(N + 1);
  int ncycles = 0;
  for (int u = (1), _b = (N); u <= _b; ++u) {
    if (seen[u]) continue;
    ++ncycles;
    for (int x = u;; x = P[x]) {
      if (seen[x]) break;
      seen[x] = true;
    }
  }
  int res = ncycles == 1 ? 0 : ncycles;
  int n0 = 0, n1 = 0;
  for (int u = (1), _b = (N); u <= _b; ++u) {
    if (B[u] == 0)
      ++n0;
    else
      ++n1;
  }
  if ((n1 % 2) == 0) ++res;
  return res;
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N;
  P = vector<int>(N + 1);
  for (int i = (1), _b = (N); i <= _b; ++i) cin >> P[i];
  B = vector<int>(N + 1);
  for (int i = (1), _b = (N); i <= _b; ++i) cin >> B[i];
  int res = solve();
  cout << res << '\n';
  return 0;
}
