#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
bool vis[N];
int p[N], b[N];
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> p[i], p[i]--;
  int sum = 0;
  for (int i = 0; i < n; i++) cin >> b[i], sum += b[i];
  int cnt = 0;
  for (int i = 0; i < n; i++)
    if (!vis[i]) {
      cnt++;
      for (int j = i; !vis[j]; j = p[j]) vis[j] = true;
    }
  int ans = cnt;
  if (ans == 1) ans = 0;
  if (sum % 2 == 0) ans++;
  cout << ans << endl;
}
