#include <bits/stdc++.h>
using namespace std;
const int nmax = 200005;
const long long inf = 2e18;
const int mod = 1000000009;
int N, M, sol, cnt, nr;
bool viz[nmax];
vector<int> G[nmax];
void DFS(int nod) {
  viz[nod] = true;
  for (auto it : G[nod])
    if (!viz[it]) DFS(it);
}
int main() {
  int i, j;
  cin >> N;
  for (i = 1; i <= N; ++i) {
    cin >> j;
    G[i].push_back(j);
  }
  for (i = 1; i <= N; ++i) {
    cin >> j;
    if (j) ++nr;
  }
  for (i = 1; i <= N; ++i)
    if (!viz[i]) DFS(i), ++cnt;
  --cnt;
  if (cnt) ++cnt;
  if (nr % 2 == 0) ++cnt;
  cout << cnt << '\n';
  return 0;
}
