#include <bits/stdc++.h>
using namespace std;
int n;
int p[200005];
int set_num[200005], sum[200005];
int cnt;
bool has = false;
int ss[200005], pos, t;
;
set<int> s;
set<int>::iterator it;
int find_set(int x) {
  return set_num[x] == x ? x : set_num[x] = find_set(set_num[x]);
}
void init() {
  for (int i = 1; i <= n; i++) set_num[i] = i;
}
int main() {
  scanf("%d", &n);
  init();
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &sum[i]);
    if (sum[i]) t++;
  }
  for (int i = 1; i <= n; i++) {
    if (find_set(i) != find_set(p[i])) {
      sum[set_num[i]] += sum[set_num[p[i]]];
      set_num[set_num[p[i]]] = set_num[set_num[i]];
    }
  }
  for (int i = 1; i <= n; i++) s.insert(find_set(i));
  cnt += s.size();
  if (t % 2 == 0) cnt++;
  if (s.size() == 1) cnt--;
  cout << cnt;
  return 0;
}
