#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++) cin >> p[i], p[i]--;
  for (int i = 0; i < n; i++) cin >> b[i];
  vector<bool> visited(n, false);
  vector<vector<int> > scc;
  queue<int> q;
  for (int i = 0; i < n; i++) {
    vector<int> temp;
    if (!visited[i]) {
      q.push(i);
      while (!q.empty()) {
        int u = q.front();
        q.pop();
        visited[u] = 1;
        temp.push_back(u);
        if (!visited[p[u]]) q.push(p[u]);
      }
      scc.push_back(temp);
    }
  }
  int ans = scc.size();
  if (ans == 1) ans = 0;
  int c = 0;
  for (int i = 0; i < n; i++) {
    if (b[i]) c++;
  }
  if (c % 2 == 0) ans++;
  cout << ans << endl;
  return 0;
}
