#include <bits/stdc++.h>
using namespace std;
int ans = 0, visited[200005] = {0};
vector<int> edges[200005];
void dfs(int x) {
  visited[x] = 1;
  if (visited[edges[x][0]] == 1)
    ans++;
  else
    dfs(edges[x][0]);
}
int main() {
  int n, i, x, count = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x;
    edges[i].push_back(x);
  }
  for (i = 1; i <= n; i++) {
    cin >> x;
    if (x == 1) count++;
  }
  for (i = 1; i <= n; i++)
    if (visited[i] == 0) dfs(i);
  if (ans == 1) ans = 0;
  if (count % 2 == 0) ans++;
  cout << ans;
}
