#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200008];
int n;
int vis[200008] = {0};
void dfs(int u) {
  if (vis[u]) return;
  vis[u] = 1;
  int sz = adj[u].size();
  for (int i = 0; i < sz; i++) {
    int v = adj[u][i];
    dfs(v);
  }
}
int main() {
  scanf("%d", &n);
  for (int u = 0; u < n; u++) {
    int v;
    scanf("%d", &v);
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int u;
    scanf("%d", &u);
    if (u) ans++;
  }
  int a = 0;
  if (ans % 2)
    a = 0;
  else
    a = 1;
  ans = 0;
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      ans++;
      dfs(i);
    }
  }
  if (ans == 1) ans = 0;
  printf("%d", ans + a);
}
