#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = ({
    int _x;
    scanf("%d", &_x);
    _x;
  });
  vector<int> p(n + 1);
  for (int i = 0; i < n; ++i) {
    p[i + 1] = ({
      int _x;
      scanf("%d", &_x);
      _x;
    });
  }
  vector<int> b(n + 1);
  int cntOnes = 0;
  for (int i = 0; i < n; ++i) {
    b[i + 1] = ({
      int _x;
      scanf("%d", &_x);
      _x;
    });
    cntOnes += (b[i + 1] == 1);
  }
  int cnt = 0;
  if (cntOnes % 2 == 0) {
    ++cnt;
  }
  int cntCycles = 0;
  vector<bool> mark(n + 1, false);
  for (int i = 1; i < n + 1; ++i) {
    if (mark[i]) {
      continue;
    }
    mark[i] = true;
    int curr = i;
    while (i != p[curr]) {
      curr = p[curr];
      mark[curr] = true;
    }
    ++cntCycles;
  }
  if (cntCycles == 1) {
    cout << cnt << endl;
  } else {
    cout << cnt + cntCycles << endl;
  }
  return 0;
}
