#include <bits/stdc++.h>
using namespace std;
vector<long long> g[2000000];
bool u[2000000];
void dfs(int v) {
  u[v] = true;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (!u[to]) {
      dfs(to);
    }
  }
}
long long n, a[222222], s, ans, comp = 0;
bool b[222222];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    g[a[i]].push_back(i);
    g[i].push_back(a[i]);
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    s += b[i];
  }
  for (int i = 1; i <= n; i++) {
    if (!u[i]) {
      dfs(i);
      comp++;
    }
  }
  if (comp == 1) {
    comp = 0;
  }
  if (s % 2 == 0) {
    cout << comp + 1;
  } else {
    cout << comp;
  }
  return 0;
}
