#include <bits/stdc++.h>
using namespace std;
int n;
int p[200003];
int b[200003];
int graph[200003];
int visited[200003];
int groups = 0;
void dfs(int nd) {
  if (visited[nd]) return;
  visited[nd] = true;
  dfs(graph[nd]);
}
int main() {
  memset(visited, 0, sizeof(visited));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &graph[i]);
  }
  int bs = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
    bs += b[i];
  }
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      groups++;
      dfs(i);
    }
  }
  int flip = 1;
  for (int i = 0; i < n; i++)
    if (b[i]) flip = !flip;
  flip = (flip == 1);
  int ans = 0;
  if (groups > 1) ans += groups;
  if (bs == 0)
    ans += 1;
  else
    ans += flip;
  printf("%d", ans);
  return 0;
}
