#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int hops[n + 1];     bool vis[n + 1];     int change[n + 1];     for (int i = 1; i <= n; ++i) {       cin >> hops[i];       vis[i] = 0;     }     int cnt = 0;     int cnt1 = 0;     for (int i = 1; i <= n; ++i) {       cin >> change[i];       if (change[i]) cnt1++;     }     for (int i = 1; i <= n; ++i) {       if (!vis[i]) {         int j = i;         cnt++;         while (vis[hops[j]] == false) {           j = hops[j];           vis[j] = true;         }       }     }     if (cnt1 % 2)       cnt1 = 0;     else       cnt1 = 1;     if (cnt == 1) cnt = 0;     cout << cnt + cnt1 << endl;   }   