#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300000;
int n;
int p[MAXN];
int b = 0;
int ct = 0;
bool vis[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
    p[i]--;
  }
  for (int i = 0; i < n; ++i) {
    int c;
    cin >> c;
    b ^= c;
  }
  for (int i = 0; i < n; ++i) {
    if (!vis[i]) {
      ++ct;
      int j = i;
      while (!vis[j]) {
        vis[j] = 1;
        j = p[j];
      }
    }
  }
  int ans = 0;
  if (ct > 1) ans = ct;
  if (b == 0) ans++;
  cout << ans << endl;
}
