#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> p(n + 1);
  vector<int> b(n + 1);
  vector<int> used(n + 1, 0);
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
  }
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> b[i];
    cnt += b[i];
  }
  int answer = 0;
  if (cnt % 2 == 0) ++answer;
  int flips = 0;
  for (int i = 1; i <= n; ++i) {
    if (!used[i]) {
      ++flips;
      int current = i;
      while (!used[current]) {
        used[current] = 1;
        current = p[current];
      }
    }
  }
  if (flips != 1) answer += flips;
  cout << answer;
  return 0;
}
