#include <bits/stdc++.h>
const int MAXN = 2e5 + 15;
using namespace std;
bool vis[MAXN];
int A[MAXN];
void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> A[i];
  int y = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x == 1) y++;
  }
  int c = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      c++;
      int x = A[i];
      vis[x] = 1;
      while (x != i) {
        x = A[x];
        vis[x] = 1;
      }
    }
  }
  cout << c + (y % 2 == 0) - (c == 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  cout << fixed << setprecision(12);
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
    cout << "\n";
  }
  return 0;
}
