#include <bits/stdc++.h>
using namespace std;
long long int n, p[200007], b[200007], nxt[200007];
bool v[200007];
void dfs(long long int x) {
  v[x] = 1;
  if (!v[nxt[x]]) dfs(nxt[x]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  long long int x = 0;
  for (long long int i = 1; i <= n; ++i) cin >> nxt[i];
  for (long long int i = 1; i <= n; ++i) {
    cin >> b[i];
    x += b[i];
  }
  long long int cnt = 0;
  for (long long int i = 1; i <= n; ++i) {
    if (!v[i]) {
      cnt++;
      dfs(i);
    }
  }
  cout << (cnt == 1 ? 0 : cnt) + (1 - x % 2) << '\n';
  return 0;
}
