#include <bits/stdc++.h>
using namespace std;
int vis[200009];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int ans = 0, c = 0;
  int p[n + 1], b[n + 1];
  for (int i = 1; i <= n; i++) cin >> p[i];
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    c += b[i];
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      cnt++;
      for (int j = i; !vis[j]; j = p[j]) vis[j] = 1;
    }
  }
  ans = cnt;
  if (ans == 1) ans = 0;
  if (c % 2 == 0) ans += 1;
  cout << ans << '\n';
  return 0;
}
