#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
bool used[N];
vector<int> p;
void dfs(int v) {
  used[v] = true;
  if (used[p[v]]) return;
  dfs(p[v]);
}
int main() {
  int n;
  cin >> n;
  int ans = 0, cnt = 0;
  vector<int> b(n + 1);
  p.resize(n + 1);
  for (int i = 1; i <= n; i++) cin >> p[i];
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      dfs(i);
      cnt++;
    }
  }
  if (cnt != 1) ans += cnt;
  cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    if (b[i]) cnt++;
  }
  if (cnt % 2 == 0) ans++;
  cout << ans;
}
