#include <bits/stdc++.h>
using namespace std;
int visited[200010];
int key[200010];
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> key[i + 1];
  }
  int a, ones = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    ones += a;
  }
  int cur, tot = 0;
  for (int i = 0; i < n; i++) {
    if (visited[i + 1] == 1) {
      continue;
    }
    cur = i + 1;
    tot++;
    while (true) {
      if (visited[cur] == 1) {
        break;
      }
      visited[cur] = 1;
      cur = key[cur];
    }
  }
  if (tot == 1) {
    tot--;
  }
  if (ones % 2 == 0) {
    tot += 1;
  }
  cout << tot;
}
