#include <bits/stdc++.h>
using namespace std;
const long long maxn = (long long)2e5 + 9;
const long long mod = (long long)1e9 + 7;
vector<int> adjlist(maxn);
vector<bool> vis(maxn);
void dfs(int);
int main() {
  std::ios::sync_with_stdio(0);
  long long i, j, k, t, q, m, l, r, n, cnt = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> j;
    adjlist[i] = j;
  }
  for (i = 1; i <= n; i++) {
    if (!vis[i]) {
      cnt++;
      dfs(i);
    }
  }
  if (cnt == 1) cnt = 0;
  bool f = 1;
  for (i = 1; i <= n; i++) {
    cin >> j;
    f ^= j;
  }
  cnt += f;
  cout << cnt << '\n';
}
void dfs(int node) {
  vis[node] = true;
  if (!vis[adjlist[node]]) dfs(adjlist[node]);
}
