#include <bits/stdc++.h>
using namespace std;
int n;
int p[200001];
bool b[200001];
int first[200001];
int last[200001];
int rez, cycles;
bool done[200001];
void readFile() {
  scanf("%d", &n);
  int i;
  for (i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (i = 1; i <= n; i++) scanf("%d", &b[i]);
}
int ant;
void cycle(int i) {
  if (done[i] != 0) return;
  ant = i;
  done[i] = 1;
  cycle(p[i]);
}
int side;
void doCycles(int i) {
  if (done[i] != 0) return;
  if (b[i] == 1) side = 1 - side;
  done[i] = 1;
  doCycles(p[i]);
}
void solve() {
  int i;
  for (i = 1; i <= n; i++) {
    if (done[i] == 0) {
      ant = 0;
      cycles++;
      first[cycles] = i;
      cycle(i);
      last[cycles] = ant;
    }
  }
  if (cycles > 1) rez += cycles;
  for (i = 1; i < cycles; i++) {
    p[last[i]] = first[i + 1];
    p[last[i + 1]] = first[i];
  }
  memset(done, 0, sizeof(done));
  side = b[1];
  doCycles(1);
  if (side == b[1]) rez++;
}
void printFile() { printf("%d\n", rez); }
int main() {
  readFile();
  solve();
  printFile();
  return 0;
}
