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