#include <bits/stdc++.h>
using namespace std;
const int maxN = 200005;
int P[maxN];
int color[maxN];
int cycle_count = 0;
void dfs(int s) {
  color[s] = 1;
  if (color[P[s]] == 0)
    dfs(P[s]);
  else if (color[P[s]] == 1)
    ++cycle_count;
  color[s] = 2;
}
int main() {
  int n;
  cin >> n;
  int res = 1;
  for (int i = 1; i <= n; ++i) scanf("%d", &P[i]);
  for (int i = 1; i <= n; ++i) {
    int b;
    scanf("%d", &b);
    res ^= b;
  }
  for (int i = 1; i <= n; ++i)
    if (color[i] == 0) dfs(i);
  if (cycle_count > 1) res += cycle_count;
  cout << res << endl;
  return 0;
}
