#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 2;
vector<int> arr[MAXN];
bool d[MAXN];
void dfs(int v) {
  d[v] = true;
  for (int i = 0; i < arr[v].size(); ++i) {
    if (!d[arr[v][i]]) dfs(arr[v][i]);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, kol_1 = 0, x, sum_comp = 0, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> x;
    arr[i].push_back(x);
  }
  for (int i = 1; i <= n; ++i) {
    cin >> x;
    kol_1 += x;
  }
  for (int i = 1; i <= n; ++i) {
    if (!d[i]) {
      sum_comp++;
      dfs(i);
    }
  }
  if (sum_comp == 1) --sum_comp;
  ans = sum_comp + int(!(kol_1 & 1));
  cout << ans;
}
