#include <bits/stdc++.h>
using namespace std;
int A[300000 + 10];
int B[300000 + 10];
int visited[300000 + 10];
void dfs(int u) {
  if (visited[u]) return;
  visited[u] = true;
  dfs(A[u]);
}
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 cnt = 0;
  for (int i = 1; i <= N; i++) {
    if (!visited[i]) {
      cnt += 1;
      dfs(i);
    }
  }
  int x = 0;
  for (int i = 1; i <= N; i++) {
    x = (x + B[i]) % 2;
  }
  int ans = (x == 0);
  if (cnt > 1) {
    ans += cnt;
  }
  printf("%d\n", ans);
}
