#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void chkmax(T& x, U y) {
  if (x < y) x = y;
}
template <typename T, typename U>
inline void chkmin(T& x, U y) {
  if (y < x) x = y;
}
const int MAXN = 333333;
int a[MAXN], b[MAXN], chk[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  int tot = 0;
  for (int i = 1; i <= n; i++)
    if (!chk[i]) {
      tot++;
      for (int j = i; !chk[j]; chk[j] = 1, j = a[j])
        ;
    }
  if (tot == 1) tot = 0;
  int sum = 0;
  for (int i = 1; i <= n; i++) sum += b[i];
  if (sum + 1 & 1) tot++;
  cout << tot << endl;
  return 0;
}
