#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n, br = 0, z = 0, ans;
int b[N], o[N];
vector<int> V[N];
void dfs(int i) {
  o[i] = 1;
  if (o[V[i][0]]) {
    z = 1;
    return;
  } else
    dfs(V[i][0]);
  if (z == 1) return;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    V[i].push_back(x);
  }
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (int i = 1; i <= n; i++) o[i] = 0;
  br = 0;
  for (int i = 1; i <= n; i++)
    if (!o[i]) {
      z = 0;
      br++;
      dfs(i);
    }
  if (br == 1)
    ans = 0;
  else
    ans = br;
  br = 0;
  for (int i = 1; i <= n; i++)
    if (b[i] == 1) br++;
  if (!(br % 2)) ans++;
  printf("%d", ans);
  return 0;
}
