#include <bits/stdc++.h>
using namespace std;
vector<int> mp[200010];
int isr[200010], cnt = 1;
int vis[200010];
void dfs(int root);
int main() {
  int n, ans = 0, num;
  bool flag = false;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &num);
    mp[i].push_back(num);
  }
  num = 0;
  for (int i = 1; i <= n; i++) scanf("%d", &isr[i]);
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i);
      cnt++;
    }
  }
  if (cnt > 2) ans = cnt - 1;
  for (int i = 1; i <= n; i++) {
    if (isr[i] == 1) {
      num++;
    }
  }
  if (num % 2 == 0) ans++;
  printf("%d", ans);
}
void dfs(int root) {
  vis[root] = cnt;
  for (int i = 0; i < mp[root].size(); i++) {
    int son = mp[root][i];
    if (!vis[son]) dfs(son);
  }
}
