#include <bits/stdc++.h>
using namespace std;
struct elem {
  int dude, boy;
};
elem v[200005];
bitset<200005> ap;
int n, howmany, x, ans;
void go_visit(int pos) {
  ap[pos] = 1;
  if (ap[v[pos].dude] == 0) go_visit(v[pos].dude);
  if (ap[v[pos].boy] == 0) go_visit(v[pos].boy);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    v[i].dude = x;
    v[x].boy = i;
  }
  for (int i = 1; i <= n; i++) {
    cin >> x;
    howmany += x;
  }
  ans += (howmany + 1) % 2;
  for (int i = 1; i <= n; i++) {
    if (ap[i]) continue;
    ans++;
    go_visit(i);
  }
  if (ans - ((howmany + 1) % 2) == 1) ans--;
  cout << ans;
  return 0;
}
