#include <bits/stdc++.h>
using namespace std;
int par[200005];
int f(int x) {
  if (x == par[x])
    return x;
  else
    return par[x] = f(par[x]);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) par[i] = i;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    int u = f(x), v = f(i);
    if (u != v) par[u] = v;
  }
  int nol = 0, satu = 0;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (x == 0)
      nol++;
    else
      satu++;
  }
  int ans = 0;
  if (nol == n || satu % 2 == 0) ans++;
  int banyak = 0;
  for (int i = 1; i <= n; i++)
    if (i == f(i)) banyak++;
  if (banyak > 1) ans += banyak;
  printf("%d\n", ans);
  return 0;
}
