#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 4;
vector<long long> g[N];
bool visited[N];
void dfs(int node) {
  visited[node] = true;
  for (int i : g[node]) {
    if (!visited[i]) dfs(i);
  }
}
int main() {
  long long n;
  cin >> n;
  long long x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    g[i + 1].push_back(x);
    g[x].push_back(i + 1);
  }
  long long b[n];
  long long o = 0;
  for (int i = 0; i < n; i++) cin >> b[i], o += b[i];
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      dfs(i);
      ans++;
    }
  }
  o %= 2;
  if (ans == 1) ans--;
  if (!o)
    cout << ans + 1;
  else
    cout << ans;
  return 0;
}
