#include <bits/stdc++.h>
using namespace std;
int a[300005];
int b[300005];
int c[300005];
int main() {
  ios::sync_with_stdio(false);
  int i, j, k, m, n, ans = 0, temp = 0;
  cin >> n;
  for (i = 1; i <= n; ++i) cin >> a[i];
  for (i = 1; i <= n; ++i) {
    temp = a[i];
    if (a[i]) ++ans;
    a[i] = 0;
    while (a[temp]) {
      int kk = temp;
      temp = a[temp];
      a[kk] = 0;
    }
  }
  if (ans == 1) ans = 0;
  for (i = 1; i <= n; ++i) cin >> b[i];
  int num = 0;
  for (i = 1; i <= n; ++i) {
    if (b[i] == 1) ++num;
  }
  if (num % 2 == 0) ++ans;
  cout << ans;
  return 0;
}
