#include <bits/stdc++.h>
using namespace std;
const long long int INF = 987698769876988899LL;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
vector<int> G[N];
int n, p[N], b[N], vis[N], pos[N];
int cycles, f = 0;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      ++cycles;
      int cur = i;
      while (!vis[cur]) {
        vis[cur] = 1;
        cur = p[cur];
      }
    }
  }
  if (cycles == 1) cycles = 0;
  int ans = cycles;
  int c = 0;
  for (int i = 1; i <= n; i++) {
    if (b[i] == 1) c++;
  }
  cout << ans + (c % 2 == 0) << endl;
}
