#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200009];
int isl = 0;
bool vis[200009];
void dfs(int i) {
  vis[i] = true;
  for (int x : adj[i])
    if (!vis[x]) dfs(x);
}
int main() {
  int n, x, y;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    adj[i].push_back(x);
  }
  x = 0;
  for (int i = 1; i <= n; i++) {
    cin >> y;
    if (y == 1) x++;
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      isl++;
      dfs(i);
    }
  if (isl == 1) isl = 0;
  cout << isl + 1 - (x % 2);
}
