#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) {
  if (y == 0) return 1ll;
  if (y % 2)
    return (x % 1000000007 * power(x, y - 1) % 1000000007) % 1000000007;
  else
    return power((x * x) % 1000000007, y / 2) % 1000000007;
}
bool vis[200005];
vector<long long> v[200005];
void dfs(int i) {
  vis[i] = true;
  for (auto j : v[i]) {
    if (vis[j] == false) dfs(j);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, cnt = 0;
  cin >> n;
  int x;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    vis[i] = false;
    v[i].push_back(x);
    v[x].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i] == false) {
      cnt++;
      dfs(i);
    }
  }
  if (cnt == 1) cnt--;
  int b[n], cnt1 = 0;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    if (b[i]) cnt1++;
  }
  if (cnt1 % 2 == 0) cnt++;
  cout << cnt << "\n";
}
