#include <bits/stdc++.h>
using namespace std;
class TaskC {
 public:
  vector<vector<long long> > g;
  void dfs(long long v) {
    used[v] = 1;
    for (long long i = 0; i < g[v].size(); i++)
      if (!used[g[v][i]]) dfs(g[v][i]);
    return;
  }
  vector<bool> used;
  void solve(std::istream& cin, std::ostream& cout) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n;
    cin >> n;
    vector<long long> v(n);
    used.resize(n, false);
    g.resize(n);
    for (long long i = 0; i < n; i++) {
      cin >> v[i];
      v[i]--;
      g[i].push_back(v[i]);
      g[v[i]].push_back(i);
    }
    long long sum = 0;
    for (long long i = 0; i < n; i++) {
      long long k;
      cin >> k;
      sum += k;
    }
    long long ans = 0;
    for (long long i = 0; i < n; i++) {
      if (!used[i]) dfs(i), ans++;
    }
    if (ans == 1) ans = 0;
    cout << ans + (sum + 1) % 2;
  }
};
int main() {
  TaskC solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
