#include <bits/stdc++.h>
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie();
  int n;
  std::cin >> n;
  std::vector<int> p(n), v(n, 0), b(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> p[i];
    p[i]--;
  }
  int rev = 0;
  for (int i = 0; i < n; ++i) {
    std::cin >> b[i];
    rev += b[i];
  }
  rev %= 2;
  int nc = 0;
  for (int i = 0; i < n; ++i)
    if (!v[i]) {
      nc++;
      v[i] = nc;
      v[p[i]] = nc;
      int j = p[i];
      while (j != i) {
        j = p[j];
        v[j] = nc;
      }
    }
  if (nc == 1) nc--;
  int ans = nc + !rev;
  std::cout << ans << std::endl;
  return 0;
}
