#include <bits/stdc++.h>
int a[200008], b[200008], vis[200008];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", b + i);
    if (b[i] & 1) ans++;
  }
  int s = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i])
      ;
    else {
      s++;
      vis[i] = 1;
      int fk = a[i];
      while (fk != i) {
        vis[fk] = 1;
        fk = a[fk];
      }
    }
  }
  if (s == 1) s = 0;
  if (ans & 1)
    ans = 0;
  else
    ans = 1;
  ans += s;
  printf("%d\n", ans);
}
