#include <bits/stdc++.h>
using namespace std;
long long int ans, boo[200002], vis[200002], per[200002], f;
vector<int> v[200002];
void dfs(long long int no, long long int paa, long long int nu) {
  vis[no] = nu;
  for (int i = 0; i < v[no].size(); i++) {
    if (vis[v[no][i]] == 0)
      dfs(v[no][i], paa + boo[no], nu + 1);
    else {
      if (vis[v[no][i]] != 1) f = 1;
    }
  }
}
int main() {
  long long int n, p = 0, sum = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> per[i], v[i].push_back(per[i]);
  for (int i = 1; i <= n; i++) cin >> boo[i], sum += boo[i];
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      dfs(i, 0, 1);
      p++;
    }
  }
  if (sum % 2 == 0) ans++;
  if (p == 1 && f == 1) ans++;
  cout << ans + (p == 1 ? 0 : p);
}
