#include <bits/stdc++.h>
using namespace std;
int used[200200], p[200200];
int n, b, ans = 0;
void dfs(int i) {
  used[i] = 1;
  if (!used[p[i]]) dfs(p[i]);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i];
  int coef = 0;
  for (int i = 1; i <= n; i++) {
    cin >> b;
    coef += b;
  }
  coef %= 2;
  coef ^= 1;
  memset(used, 0, sizeof used);
  for (int i = 1; i <= n; i++) {
    if (!used[i]) dfs(i), ans++;
  }
  if (ans == 1) ans--;
  cout << ans + coef << endl;
  return 0;
}
