#include <bits/stdc++.h>
using namespace std;
const int MAX = 200010;
int p[MAX], vis[MAX];
void dfs(int x) {
  if (vis[x] == 1) return;
  vis[x] = 1;
  dfs(p[x]);
}
int main(int argc, char const *argv[]) {
  int n;
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &p[i]);
    }
    int cnt = 1, tmp;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &tmp);
      cnt = cnt ^ tmp;
    }
    int ans = 0;
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= n; i++)
      if (!vis[i]) {
        ans++;
        dfs(i);
      }
    if (ans == 1) {
      ans = 0;
    }
    printf("%d\n", ans + cnt);
  }
  return 0;
}
