#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200000 + 5;
int n;
int p[MAXN];
bool vis[MAXN];
void dfs(int i) {
  vis[i] = 1;
  if (!vis[p[i]]) dfs(p[i]);
}
void dance() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  dance();
  int i;
  cin >> n;
  for (i = 1; i <= n; ++i) {
    cin >> p[i];
  }
  int ans = 0;
  for (i = 1; i <= n; ++i) {
    if (!vis[i]) {
      dfs(i);
      ans++;
    }
  }
  if (ans == 1) ans--;
  int sum = 0;
  int x;
  for (i = 0; i < n; ++i) {
    cin >> x;
    if (x) sum++;
  }
  if (sum % 2 == 0) ans++;
  cout << ans;
  return 0;
}
