#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200001];
bool vis[200001];
int en = -1;
int a[200005], b[200005];
void dfs(int x) {
  vis[x] = 1;
  for (auto it = adj[x].begin(); it != adj[x].end(); ++it) {
    if (!vis[*it]) {
      dfs(*it);
    }
  }
  if (en == -1) en = x;
}
int main() {
  int n, m, i, k, l = 0, ans = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    adj[i].push_back(a[i]);
  }
  int flag = 0;
  for (i = 1; i <= n; i++) {
    cin >> b[i];
    if (b[i]) flag++;
  }
  if (!flag)
    ans++;
  else if (flag % 2 == 0)
    ans++;
  int temp = -1;
  for (i = 1; i <= n; i++) {
    if (!vis[i]) {
      temp = en;
      en = -1;
      dfs(i);
      adj[en].clear();
      if (temp > 0) {
        ans++;
        adj[temp].push_back(i);
      }
    }
  }
  if (temp != -1) {
    adj[en].push_back(1);
    ans++;
  }
  cout << ans;
  return 0;
}
