#include <bits/stdc++.h>
using namespace std;
bool v[200055];
int p[200055], b[200055];
int main() {
  int n, sum = 0, c = 0, ans;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> p[i], p[i]--;
  for (int i = 0; i < n; i++) cin >> b[i], sum += b[i];
  for (int i = 0; i < n; i++)
    if (!v[i]) {
      c++;
      for (int j = i; !v[j]; j = p[j]) v[j] = true;
    }
  ans = c;
  if (ans == 1) ans = 0;
  if (sum % 2 == 0) ans++;
  cout << ans << endl;
  return 0;
}
