Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the reversed direction.

Pavel has a plan: a permutation p and a sequence b1, b2, ..., bn, consisting of zeros and ones. Each second Pavel move skewer on position i to position pi, and if bi equals 1 then he reverses it. So he hope that every skewer will visit every position in both directions.

Unfortunately, not every pair of permutation p and sequence b suits Pavel. What is the minimum total number of elements in the given permutation p and the given sequence b he needs to change so that every skewer will visit each of 2n placements? Note that after changing the permutation should remain a permutation as well.

There is no problem for Pavel, if some skewer visits some of the placements several times before he ends to cook. In other words, a permutation p and a sequence b suit him if there is an integer k (k ≥ 2n), so that after k seconds each skewer visits each of the 2n placements.

It can be shown that some suitable pair of permutation p and sequence b exists for any n.

Input

The first line contain the integer n (1 ≤ n ≤ 2·105) — the number of skewers.

The second line contains a sequence of integers p1, p2, ..., pn (1 ≤ pi ≤ n) — the permutation, according to which Pavel wants to move the skewers.

The third line contains a sequence b1, b2, ..., bn consisting of zeros and ones, according to which Pavel wants to reverse the skewers.

Output

Print single integer — the minimum total number of elements in the given permutation p and the given sequence b he needs to change so that every skewer will visit each of 2n placements.

Examples

Input

4
4 3 2 1
0 1 1 1


Output

2


Input

3
2 3 1
0 0 0


Output

1

Note

In the first example Pavel can change the permutation to 4, 3, 1, 2.

In the second example Pavel can change any element of b to 1.
#include <bits/stdc++.h>
using namespace std;
long long int tmod(long long int x, long long int m) { return (x % m + m) % m; }
class UnionFind {
 public:
  vector<int> p, rank;
  UnionFind(int N) {
    rank.assign(N, 1);
    p.assign(N, 0);
    for (int i = 0; i < N; i++) p[i] = i;
  }
  int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
  bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
  void unionSet(int i, int j) {
    if (!isSameSet(i, j)) {
      int x = findSet(i), y = findSet(j);
      if (rank[x] > rank[y])
        p[y] = x, rank[x] += rank[y];
      else {
        p[x] = y;
        rank[y] += rank[x];
      }
    }
  }
};
bool is_intersection(int l, int r, int ll, int rr) {
  if (r < ll || rr < l) return 0;
  return 1;
}
struct node {
  int mn, mx, l, r;
};
class RMQ {
 public:
  vector<int> h;
  vector<node> st;
  RMQ(vector<int> a) {
    h = a;
    st.resize(4 * h.size());
    build(0, h.size() - 1);
  }
  void build(int l, int r, int k = 0) {
    st[k].l = l, st[k].r = r;
    if (l == r) {
      st[k].mx = st[k].mn = l;
      return;
    }
    build(l, (l + r) / 2, 2 * k + 1);
    build((l + r) / 2 + 1, r, 2 * k + 2);
    if (h[st[2 * k + 1].mn] <= h[st[2 * k + 2].mn])
      st[k].mn = st[2 * k + 1].mn;
    else
      st[k].mn = st[2 * k + 2].mn;
    if (h[st[2 * k + 1].mx] >= h[st[2 * k + 2].mx])
      st[k].mx = st[2 * k + 1].mx;
    else
      st[k].mx = st[2 * k + 2].mx;
  }
  int minquery(int l, int r, int k = 0) {
    if (l > r) return 1000000000;
    int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2;
    if (ll >= l && rr <= r) return st[k].mn;
    int ans = l;
    if (is_intersection(ll, mid, l, r) == 1) ans = minquery(l, r, 2 * k + 1);
    if (is_intersection(mid + 1, rr, l, r) == 1) {
      if (h[ans] > h[minquery(l, r, 2 * k + 2)])
        ans = minquery(l, r, 2 * k + 2);
    }
    return ans;
  }
  int maxquery(int l, int r, int k = 0) {
    if (l > r) return -1000000000;
    int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2;
    if (ll >= l && rr <= r) return st[k].mx;
    int ans = l;
    if (is_intersection(ll, mid, l, r) == 1) ans = maxquery(l, r, 2 * k + 1);
    if (is_intersection(1 + mid, rr, l, r) == 1) {
      if (h[ans] < h[maxquery(l, r, 2 * k + 2)])
        ans = maxquery(l, r, 2 * k + 2);
    }
    return ans;
  }
  void update(int id, int val, int k = 0) {
    int l = st[k].l, r = st[k].r, mid = (l + r) / 2;
    if (l == r) {
      h[l] = val;
      return;
    }
    if (is_intersection(l, mid, id, id) == 1) update(id, val, 2 * k + 1);
    if (is_intersection(mid + 1, r, id, id) == 1) update(id, val, 2 * k + 2);
    if (h[st[2 * k + 1].mn] <= h[st[2 * k + 2].mn])
      st[k].mn = st[2 * k + 1].mn;
    else
      st[k].mn = st[2 * k + 2].mn;
    if (h[st[2 * k + 1].mx] >= h[st[2 * k + 2].mx])
      st[k].mx = st[2 * k + 1].mx;
    else
      st[k].mx = st[2 * k + 2].mx;
  }
};
long long int power(long long int x, long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  if (res < 0) res += 1000000007;
  return res;
}
long long int modInverse(long long int a, long long int m) {
  long long int m0 = m;
  long long int y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long int q = a / m;
    long long int t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int p[n], b[n];
  for (long long int i = 0; i < n; i++) cin >> p[i];
  for (long long int i = 0; i < n; i++) cin >> b[i];
  int sum = 0;
  for (long long int i = 0; i < n; i++) sum += b[i];
  UnionFind DSU(n + 1);
  for (long long int i = 0; i < n; i++) DSU.unionSet(i + 1, p[i]);
  set<int> distinct_component;
  for (long long int i = 1; i < n + 1; i++)
    distinct_component.insert({DSU.findSet(i)});
  cout << (distinct_component.size() != 1) * distinct_component.size() +
              (sum % 2 == 0);
  return 0;
}
