#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long pw(long long a, long long b) {
  long long r = 1;
  while (b > 0) {
    if (b & 1) {
      r = (r * a) % MOD;
    }
    b = b >> 1;
    a = (a * a) % MOD;
  }
  return (r) % MOD;
}
vector<int> g[200100];
int vis[200100] = {};
void dfs(int u) {
  if (vis[u]) return;
  vis[u] = 1;
  int v;
  for (int i = 0; i < g[u].size(); i++) {
    v = g[u][i];
    dfs(v);
  }
  return;
}
int main() {
  int n, first;
  cin >> n;
  vector<int> b;
  int f[2] = {};
  for (int i = 0; i < n; i++) {
    cin >> first;
    first--;
    g[i].push_back(first);
    g[first].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> first;
    f[first]++;
  }
  int cp = 0;
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      cp++;
      dfs(i);
    }
  }
  int ans = (cp > 1) ? cp : 0;
  if (f[1] % 2) {
  } else {
    ans += 1;
  }
  cout << ans;
  printf("\n");
  return 0;
}
