#include <bits/stdc++.h>
using namespace std;
const int nmax = 300010;
int n, used[nmax], p[nmax], s = 0;
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0, x; i < n; i++) cin >> x, s += x;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (used[i]) continue;
    int j = i;
    while (!used[j]) used[j] = 1, j = p[j] - 1;
    ans++;
  }
  if (ans == 1) ans--;
  if (s % 2 == 0) ans++;
  cout << ans << endl;
  return 0;
}
