#include <bits/stdc++.h>
using namespace std;
const int N = int(2e5);
int g[N];
int ans = 0;
int n;
bool used[N];
void bfs(int start) {
  queue<int> q;
  q.push(start);
  used[start] = true;
  while (!q.empty()) {
    int from = q.front();
    q.pop();
    int to = g[from];
    if (!used[to]) {
      used[to] = true;
      q.push(to);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> g[i];
    g[i]--;
  }
  int c = 0;
  for (int i = 0, t; i < n; ++i) {
    cin >> t;
    c += t;
  }
  ans += !(bool(c & 1));
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (!used[i]) {
      cnt++;
      bfs(i);
    }
  }
  ans += (cnt == 1 ? 0 : cnt);
  cout << ans;
  return 0;
}
