#include <bits/stdc++.h>
using namespace std;
bool go[200005];
int nex[200005];
int n;
void dfs(int x) {
  if (go[x]) return;
  go[x] = 1;
  dfs(nex[x]);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> nex[i];
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    cnt += x;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!go[i]) {
      ans++;
      dfs(i);
    }
  }
  if (ans == 1) ans = 0;
  cout << ans + 1 - (cnt & 1) << endl;
}
