#include <bits/stdc++.h>
using namespace std;
int N, A[202020], B[202020];
template <int um>
class UF {
 public:
  vector<int> par, rank;
  UF() {
    rank = vector<int>(um, 0);
    for (int i = 0; i < um; i++) par.push_back(i);
  }
  int operator[](int x) {
    return (par[x] == x) ? (x) : (par[x] = operator[](par[x]));
  }
  int operator()(int x, int y) {
    if ((x = operator[](x)) == (y = operator[](y))) return x;
    if (rank[x] > rank[y]) return par[x] = y;
    rank[x] += rank[x] == rank[y];
    return par[y] = x;
  }
};
UF<500000> uf;
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N;
  for (i = 0; i < (N); i++) cin >> A[i], A[i]--, uf(i, A[i]);
  x = 1;
  for (i = 0; i < (N); i++) cin >> B[i], x ^= B[i];
  int cnt = 0;
  for (i = 0; i < (N); i++)
    if (uf[i] == i) cnt++;
  if (cnt != 1) x += cnt;
  cout << x << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  solve();
  return 0;
}
