#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e6 + 7, SZ = 3 * 1e8;
const long long MODM = 1e9 + 7, INF = 1e18 + 1;
bool used[MAXN];
int p[MAXN], b[MAXN];
vector<int> bad;
void dfs(int v) {
  used[v] = 1;
  auto to = p[v];
  if (used[to]) {
    bad.push_back(to);
    return;
  }
  dfs(to);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> p[i + 1];
  }
  for (int i = 1; i <= n; ++i) {
    if (!used[i]) {
      dfs(i);
    }
  }
  int ans = bad.size();
  if (ans == 1) ans = 0;
  int cnt = 0;
  for (int j = 0; j < n; ++j) {
    cin >> b[j];
    cnt += b[j];
  }
  if (cnt % 2 == 0) ++ans;
  cout << ans;
  return 0;
}
