#include <bits/stdc++.h>
using namespace std;
long long n, a[200009], ans = 1, b[200009], sum = 1;
bool vis[200009];
void dfs(long long x) {
  if (vis[x]) return;
  vis[x] = 1;
  dfs(a[x]);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  dfs(1);
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    sum++;
    dfs(i);
  }
  bool f = 0, g = 0;
  for (int i = 1; i <= n; i++) {
    ans += b[i];
  }
  ans %= 2;
  if (sum != 1) ans += sum;
  cout << ans << endl;
  return 0;
}
