#include <bits/stdc++.h>
using namespace std;
void add_edge(int u, int v, vector<int> adj[]) { adj[u].push_back(v); }
int get_cycles(vector<int> adj[], int V) {
  bool* visited = new bool[V];
  for (int i = 0; i < V; ++i) {
    visited[i] = false;
  }
  int amount_visited = 0;
  int cycles = 0;
  int vertex = 0;
  int next_vertex = 1;
  while (amount_visited < V) {
    while (!visited[vertex]) {
      visited[vertex] = true;
      amount_visited++;
      vertex = adj[vertex][0];
    }
    cycles++;
    while (next_vertex < V && visited[next_vertex]) {
      next_vertex++;
    }
    vertex = next_vertex++;
  }
  return cycles;
}
int main() {
  int n;
  cin >> n;
  vector<int> adj[n];
  for (int i = 0; i < n; ++i) {
    int input;
    cin >> input;
    add_edge(input - 1, i, adj);
  }
  int ones = 0;
  for (int i = 0; i < n; ++i) {
    int input;
    cin >> input;
    if (input == 1) {
      ones++;
    }
  }
  int ans = 0;
  if (ones % 2 == 0) {
    ans++;
  }
  int cycles = get_cycles(adj, n);
  if (cycles > 1) {
    ans += cycles;
  }
  cout << ans << endl;
  return 0;
}
