#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1, 0);
  vector<bool> v(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int b = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    b = b + x;
  }
  int c = 0;
  for (int i = 1; i <= n; i++) {
    if (v[i]) {
      continue;
    }
    ++c;
    int u = i;
    while (!v[u]) {
      v[u] = 1;
      u = a[u];
    }
  }
  int t;
  if (c > 1) {
    if (b % 2 == 0) {
      t = c + 1;
    } else {
      t = c;
    }
  } else {
    if (b % 2 == 0) {
      t = 1;
    } else {
      t = 0;
    }
  }
  cout << t;
}
