#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5 + 10, mod = 1e9 + 7;
int p[N];
bool mark[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, c = 0, cyc = 0, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    if (t == 1) c++;
  }
  if (c % 2 == 0) ans++;
  for (int i = 1; i <= n; i++) {
    if (mark[i]) continue;
    int x = i;
    cyc++;
    while (!mark[x]) {
      mark[x] = true;
      x = p[x];
    }
  }
  ans += cyc;
  if (cyc == 1) ans--;
  cout << ans << '\n';
}
