#include <bits/stdc++.h>
using namespace std;
int arr[200008];
vector<int> tree[200008];
bool vis[200008];
void dfs(int root) {
  vis[root] = 1;
  for (int i = 0; i < tree[root].size(); i++) {
    if (!vis[tree[root][i]]) dfs(tree[root][i]);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
    tree[i].push_back(arr[i]);
  }
  int x, ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    ans += x;
  }
  ans = (ans % 2 == 0);
  int tot = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i);
      tot++;
    }
  }
  if (tot > 1)
    cout << ans + tot;
  else
    cout << ans << endl;
  return 0;
}
