#include <bits/stdc++.h>
using namespace std;
int a[200005], b[200005], vis[200005];
int dfs(int u, int flag) {
  flag += b[u];
  vis[u] = 1;
  if (!vis[a[u]])
    return dfs(a[u], flag);
  else
    return flag;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  int ok = 0, notok = 0;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      if (dfs(i, 0) % 2 == 1)
        ok++;
      else
        notok++;
    }
  int comp = ok + notok;
  if (comp == 1)
    cout << (ok ? 0 : 1) << endl;
  else {
    if (ok > 0)
      cout << comp + (ok % 2 == 0 ? 1 : 0) << endl;
    else
      cout << comp + 1 << endl;
  }
  return 0;
}
