#include <bits/stdc++.h>
using namespace std;
int p[200005], b[200005];
bool used[200005];
void dfs(int v) {
  used[v] = true;
  int to = p[v];
  if (!used[to]) dfs(to);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }
  int k = 0;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    if (b[i] == 1) k++;
  }
  k++;
  k %= 2;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      dfs(i);
      ans++;
    }
  }
  if (ans == 1) ans--;
  ans += k;
  cout << ans << endl;
}
