#include <bits/stdc++.h>
using namespace std;
const int maxn = 200009;
int fa[maxn];
int findd(int x) {
  if (fa[x] == x) {
    return x;
  }
  return fa[x] = findd(fa[x]);
}
void bcj(int x, int y) {
  int fx = findd(x);
  int fy = findd(y);
  if (fx == fy)
    return;
  else if (fx < fy) {
    fa[fy] = fx;
    fa[y] = findd(y);
  } else {
    fa[fx] = fy;
    fa[x] = findd(x);
  }
}
struct Ren {
  int f, n, id;
};
Ren ren[maxn];
int cmp(Ren a, Ren b) { return a.f < b.f; }
int main() {
  int n, aaa;
  int num[maxn];
  bool has[maxn];
  int suan[maxn];
  while (scanf("%d", &n) != EOF) {
    int cnt = 0;
    memset(has, false, sizeof(has));
    for (int i = 0; i < maxn; i++) {
      fa[i] = i;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &num[i]);
    }
    for (int i = 0; i < n; i++) {
      scanf("%d", &aaa);
      if (aaa == 1) {
        cnt++;
      }
    }
    if (cnt % 2 == 0) {
      ans++;
    }
    for (int i = 1; i <= n; i++) {
      bcj(i, num[i]);
    }
    for (int i = 1; i <= n; i++) {
      fa[i] = findd(i);
    }
    int tuan = 0;
    for (int i = 1; i <= n; i++) {
      if (has[fa[i]] == false) {
        tuan++;
        has[fa[i]] = true;
      }
    }
    if (tuan == 1) {
      memset(suan, 0, sizeof(suan));
      bool flag = true;
      for (int i = 1; i <= n; i++) {
        if (suan[num[i]] == 0) {
          suan[num[i]]++;
        } else {
          suan[num[i]]++;
          flag = false;
        }
      }
      if (flag) {
        printf("%d\n", ans);
      } else {
        for (int i = 1; i <= n; i++) {
          if (suan[i] > 1) {
            ans += suan[i] - 1;
          }
        }
        printf("%d\n", ans);
      }
    } else {
      ren[0].f = 0;
      for (int i = 1; i <= n; i++) {
        ren[i].f = fa[i];
        ren[i].n = num[i];
        ren[i].id = i;
      }
      sort(ren + 1, ren + n + 1, cmp);
      memset(suan, 0, sizeof(suan));
      bool flag = true;
      int xianzaituan = 0;
      int youwenti = 0;
      for (int i = 1; i <= n; i++) {
        if (ren[i].f != xianzaituan) {
          xianzaituan = ren[i].f;
          flag = true;
        }
        if (suan[ren[i].n] == 0) {
          ;
        } else if (suan[ren[i].n] > 0 && flag == true) {
          youwenti++;
          flag = false;
        }
        suan[ren[i].n]++;
      }
      ans += tuan;
      ans -= youwenti;
      for (int i = 1; i <= n; i++) {
        if (suan[i] > 1) {
          ans += suan[i] - 1;
        }
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
