#include <bits/stdc++.h>
using namespace std;
int Dx[] = {1, -1, 0, 0};
int Dy[] = {0, 0, 1, -1};
void fast() {
  ios::sync_with_stdio(0);
  cin.tie(0);
}
void file() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
int n, c, cc;
int x[200005];
bool vis[200005], b[200005];
void dfs(int u) {
  vis[u] = 1;
  if (!vis[x[u]]) dfs(x[u]);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> x[i];
  for (int i = 1; i <= n; i++) cin >> b[i], c += b[i];
  c++;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i), cc++;
  if (cc == 1) cc = 0;
  cout << c % 2 + cc << endl;
  return 0;
}
