#include <bits/stdc++.h>
using namespace std;
const int nmax = 2 * 1e5 + 42;
int n;
int p[nmax], b[nmax];
bool vis[nmax];
void dfs(int node) {
  if (vis[node]) return;
  vis[node] = 1;
  dfs(p[node]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  int cycles = 0;
  for (int i = 1; i <= n; i++)
    if (vis[i] == 0) {
      dfs(i);
      cycles++;
    }
  int sw = 0;
  for (int i = 1; i <= n; i++) sw = sw + (b[i]);
  cout << (cycles == 1 ? 0 : cycles) + (sw % 2 == 0 ? 1 : 0) << endl;
  return 0;
}
