#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 * 3;
int n, m, k, l, r, ans, d, p[N], b[N];
bool used[N];
vector<int> v[N];
void dfs(int x) {
  used[x] = true;
  r += b[x];
  l++;
  for (int i = 0; i < v[x].size(); ++i) {
    int to = v[x][i];
    if (!used[to]) dfs(to);
  }
}
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
    v[i].push_back(p[i]);
    v[p[i]].push_back(i);
  }
  for (int i = 1; i <= n; ++i) {
    cin >> b[i];
    r += b[i];
  }
  if (r % 2 == 0) ans = 1;
  k = 0;
  for (int i = 1; i <= n; ++i) {
    if (!used[i]) {
      dfs(i);
      k++;
      ans++;
    }
  }
  if (k > 1)
    cout << ans;
  else
    cout << ans - 1;
}
