#include <bits/stdc++.h>
using namespace std;
void dfs(int u, int p[], bool mark[]) {
  mark[u] = true;
  if (mark[p[u]]) return;
  dfs(p[u], p, mark);
}
int main() {
  int result = 0, cycle = 0;
  int n;
  cin >> n;
  int p[n + 1], b[n + 1], f = 0;
  bool mark[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
    mark[i] = false;
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    f += b[i];
  }
  if (f % 2 == 0) result++;
  for (int i = 1; i <= n; i++) {
    if (!mark[i]) {
      dfs(i, p, mark);
      cycle++;
    }
  }
  if (cycle > 1) result += cycle;
  cout << result << endl;
  return 0;
}
