#include <bits/stdc++.h>
using namespace std;
const int lim = 1e6 + 7;
int n;
int pi[lim];
int bits[lim];
bool visited[lim];
void DFS(int idx) {
  visited[idx] = true;
  if (!visited[pi[idx]]) DFS(pi[idx]);
}
void solve() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> pi[i];
  int answ = 0;
  for (int i = 1; i <= n; i++) {
    cin >> bits[i];
    answ += bits[i];
  }
  int cc = 0;
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      DFS(i);
      cc++;
    }
  }
  if (cc == 1) cc = 0;
  if (answ % 2 == 1)
    cout << cc;
  else
    cout << cc + 1;
}
int main() {
  if (fopen("d:\\lmo.in", "r") != NULL) {
    freopen("d:\\lmo.in", "r", stdin);
  } else if (fopen("/media/luismo/Pablo's Destruction/lmo.in", "r") != NULL) {
    freopen("/media/luismo/Pablo's Destruction/lmo.in", "r", stdin);
  }
  cin.sync_with_stdio(false);
  cin.tie(0);
  solve();
}
