#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n + 5], b[n + 5];
  bool visit[n + 5];
  for (int i = 1; i <= n; i++) cin >> a[i];
  int x = 0;
  for (int i = 1; i <= n; i++) {
    visit[i] = false;
    cin >> b[i];
    x += b[i];
  }
  int ans = (x + 1) % 2;
  int p = 0;
  int ans1 = 0;
  int i = 1;
  while (p < n) {
    ans1++;
    while (visit[i] == true && i <= n) {
      i++;
    }
    while (visit[i] == false) {
      visit[i] = true;
      i = a[i];
      p++;
    }
  }
  if (ans1 > 1) ans += ans1;
  cout << ans << "\n";
}
