#include <bits/stdc++.h>
using namespace std;
vector<bool> vis;
vector<vector<int> > adlist;
void dfs(int v) {
  int i, u;
  vis[v] = 1;
  for (i = 0; i < adlist[v].size(); i++) {
    u = adlist[v][i];
    if (!vis[u]) dfs(u);
  }
}
int main() {
  int n, i, p, cnt, ans, b;
  cin >> n;
  adlist.resize(n + 1);
  vis.resize(n + 1);
  for (i = 1; i <= n; i++) {
    cin >> p;
    if (p != i) {
      adlist[i].push_back(p);
    }
  }
  for (i = 1; i <= n; i++) vis[i] = 0;
  cnt = 0;
  for (i = 0; i < n; i++) {
    cin >> b;
    if (b == 1) cnt++;
  }
  ans = 0;
  for (i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i);
      ans++;
    }
  }
  if (ans == 1) {
    if (n == 1) {
      cout << (!(cnt % 2));
    } else {
      ans = 0;
      int t = 1;
      if (n > 1)
        p = adlist[1][0];
      else
        p = 1;
      while (p != 1) {
        p = adlist[p][0];
        t++;
      }
      if (t != n) ans++;
      cout << (ans + !(cnt % 2));
    }
  } else
    cout << ans + !(cnt % 2);
  return 0;
}
