#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int p[N];
bool vis[N], is[N];
void dfs(int v) {
  vis[v] = true;
  if (vis[p[v]]) return;
  dfs(p[v]);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
    --p[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> is[i];
  }
  int cnt = 0, cnt2 = 0;
  for (int i = 0; i < n; ++i) {
    if (is[i]) ++cnt2;
    if (!vis[i]) {
      ++cnt;
      dfs(i);
    }
  }
  if (cnt == 1) --cnt;
  if (cnt2 % 2 == 0) ++cnt;
  cout << cnt;
}
