#include <bits/stdc++.h>
using namespace std;
int n, p[200009], b[200009], ans, u[200009], sum;
void dfs(int v) {
  if (u[v] == 1) {
    ans++;
    return;
  }
  u[v] = 1;
  dfs(p[v]);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++) {
    if (!u[p[i]]) {
      dfs(p[i]);
    }
  }
  if (ans == 1) ans = 0;
  for (int i = 1; i <= n; i++) sum += b[i];
  if (sum % 2 == 0) ans++;
  cout << ans;
}
