#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> p(n), b(n, false);
  for (auto &el : p) {
    cin >> el;
    el--;
  }
  int sb = 0;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    sb += t;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (!b[i]) {
      ans++;
      int c = i;
      while (b[c] == false) {
        b[c] = true;
        c = p[c];
      }
    }
  }
  if (ans == 1) ans--;
  ans += (sb % 2 == 0);
  cout << ans << "\n";
}
