#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 100;
int n;
int p[maxn], b[maxn];
int fa[maxn];
set<int> st;
void Init() {
  for (int i = 1; i <= n; ++i) {
    fa[i] = i;
  }
}
int Find(int x) { return (x == fa[x] ? x : fa[x] = Find(fa[x])); }
void unit(int x, int y) {
  int xx = Find(x);
  int yy = Find(y);
  fa[xx] = yy;
}
int main() {
  ios::sync_with_stdio(false);
  while (scanf("%d", &n) != EOF) {
    st.clear();
    int ans = 1;
    Init();
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &p[i]);
      unit(p[i], i);
    }
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &b[i]);
      ans ^= b[i];
    }
    for (int i = 1; i <= n; ++i) {
      st.insert(Find(i));
    }
    ans += st.size();
    if (st.size() == 1) {
      --ans;
    }
    printf("%d\n", ans);
  }
  return 0;
}
