#include <bits/stdc++.h>
using namespace std;
int a[200010];
bool visited[200010];
int main() {
  int n;
  cin >> n;
  int cycles = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    if (visited[i]) continue;
    int curr = i;
    while (true) {
      if (visited[curr]) break;
      visited[curr] = true;
      curr = a[curr];
    }
    cycles++;
  }
  if (cycles == 1) cycles--;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt += a[i];
  }
  if (cnt % 2 == 0) cycles++;
  cout << cycles << endl;
}
