#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 9;
long long n, m;
long long int j = 1;
int arr[N];
long long a, b, c;
set<int> nodes1[N];
vector<int> nodes2[N];
map<int, int> mp;
queue<int> q;
bool visited1[N];
bool visited2[N];
char w[N];
long long ans1, ans2;
long long arr1[N], arr2[N];
string s, s1;
int k;
int max11 = -1;
long long p = 1;
vector<long long> l;
vector<long long> l1;
int sum = 0;
int path = 0;
int visited[N];
int mod = 1e9 + 7;
int color;
int path1, path2;
bool flag = false;
int skewers = 0;
int mask;
void dfs(int node) {
  mask ^= arr1[node];
  visited[node] = true;
  for (int i = 0; i < nodes2[node].size(); i++) {
    if (visited[nodes2[node][i]] == false) dfs(nodes2[node][i]);
  }
}
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a);
    nodes2[i].push_back(a);
    nodes2[a].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &arr1[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (visited[i] == false) {
      skewers++;
      dfs(i);
    }
  }
  if (skewers == 1) skewers = 0;
  cout << skewers + (1 - mask);
}
