#include <bits/stdc++.h>
using namespace std;
int a[200010];
int b[200010];
bool vis[200010];
void DFS(int u) {
  vis[u] = true;
  if (!vis[a[u]]) DFS(a[u]);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    if (b[i]) cnt++;
  }
  if (cnt & 1)
    cnt = 0;
  else
    cnt = 1;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) ans++, DFS(i);
  }
  if (ans == 1) ans--;
  printf("%d\n", cnt + ans);
  return 0;
}
