#include <bits/stdc++.h>
using namespace std;
long long int n, cnt = 0, sum = 0, ans = 0;
vector<long long int> arr(2e5 + 5);
vector<long long int> brr(2e5 + 5);
vector<bool> rec(2e5 + 5, false);
void dfs(long long int i) {
  rec[i] = true;
  if (rec[arr[i]] == false) {
    dfs(arr[i]);
  }
}
int main(void) {
  cin >> n;
  for (long long int i = 1; i < n + 1; i++) {
    cin >> arr[i];
  }
  for (long long int i = 1; i < n + 1; i++) {
    cin >> brr[i];
    sum += brr[i];
  }
  for (long long int i = 1; i < n + 1; i++) {
    if (!rec[i]) {
      cnt++;
      dfs(i);
    }
  }
  if (sum % 2 == 0) {
    ans++;
  }
  if (cnt > 1) {
    ans += cnt;
  }
  cout << ans << endl;
}
