#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
int col[N], par[N], to[N];
int num = 0;
void dfs(int u, int from) {
  if (col[u] == 2) return;
  if (col[u] == 1) {
    ++num;
    return;
  }
  col[u] = 1;
  par[u] = from;
  dfs(to[u], u);
  col[u] = 2;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, cnt = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> to[i];
  int b[N];
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (x) ++cnt;
  }
  for (int i = 1; i <= n; ++i)
    if (!col[i]) dfs(i, -1);
  if (num == 1) num = 0;
  cout << num + ((cnt % 2) ? 0 : 1);
}
