#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
int sv[5000010];
void sieve() {
  for (int i = 2; i <= sqrt(5000010); i++) {
    if (sv[i] == 0) {
      sv[i] = i;
      for (int j = i * i; j < 5000010; j += i) {
        sv[j] = i;
      }
    }
  }
}
double pow_(double a, long long b) {
  if (b == 0) {
    return 1;
  }
  if (b % 2 == 1) {
    return pow_(a, b - 1) * a;
  } else {
    double x = pow_(a, b / 2);
    return x * x;
  }
}
long long bin_s(vector<pair<long long, long long> >& v, long long x) {
  long long l = 0, r = v.size() - 1;
  while (l != r - 1) {
    long long m = (l + r) / 2;
    if (v[m].first > x) {
      r = m;
    } else {
      l = m;
    }
  }
  if (v[r].first == x) {
    return r;
  } else if (v[l].first == x) {
    return l;
  } else {
    return -1;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  srand(time(NULL));
  int n, ans = 0, sum = 0;
  cin >> n;
  vector<int> p(n), d(n);
  vector<bool> used(n, false);
  vector<pair<int, int> > cycle;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    sum += d[i];
    sum %= 2;
  }
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      v.push_back(cycle.size());
      int x = i;
      while (!used[x]) {
        cycle.push_back(pair<int, int>(p[x] - 1, x));
        used[x] = true;
        x = p[x] - 1;
      }
    }
  }
  for (ans = v.size() - 1; ans > 0; ans--) {
    swap(cycle[cycle.size() - 1].first, cycle[v[ans] - 1].first);
  }
  ans = 0;
  sort(cycle.begin(), cycle.end(), comp);
  for (int i = 0; i < n; i++) {
    if (p[i] != cycle[i].first + 1) {
      ans++;
    }
  }
  cout << ans + 1 - sum;
  return 0;
}
