#include <bits/stdc++.h>
using namespace std;
long long n, b, a, total = 0, cnt = 0;
vector<long long> perms;
vector<bool> visited;
void visit(int i) {
  if (visited[i]) return;
  visited[i] = true;
  visit(perms[i]);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    perms.push_back(a - 1);
    visited.push_back(false);
  }
  for (int i = 0; i < n; i++) {
    cin >> a;
    b += a;
  }
  if (b % 2 == 0) total++;
  for (int i = 0; i < n; i++) {
    if (!visited[i]) {
      cnt++;
      visit(i);
    }
  }
  if (cnt > 1) total += cnt;
  cout << total;
  return 0;
}
