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