#include <bits/stdc++.h>
using namespace std;
const pair<int, int> DD[] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                             {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
template <class T>
T smin(T &a, T b) {
  if (a > b) a = b;
  return a;
}
template <class T>
T smax(T &a, T b) {
  if (a < b) a = b;
  return a;
}
int main(void) {
  srand(time(0));
  cout << fixed << setprecision(7);
  cerr << fixed << setprecision(7);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  int xa = 0, xb = 0;
  for (int i = 0; i < n; ++i) cin >> a[i], xa ^= a[i];
  for (int i = 0; i < n; ++i) cin >> b[i], xb ^= b[i];
  vector<int> c = a, d = b;
  c.push_back(xa);
  d.push_back(xb);
  sort(c.begin(), c.end());
  sort(d.begin(), d.end());
  if (c != d) {
    assert(0);
  }
  vector<int> ss = c;
  ss.resize(unique(ss.begin(), ss.end()) - ss.begin());
  for (auto &it : a)
    it = lower_bound(ss.begin(), ss.end(), it) - ss.begin() + 1;
  for (auto &it : b)
    it = lower_bound(ss.begin(), ss.end(), it) - ss.begin() + 1;
  xa = lower_bound(ss.begin(), ss.end(), xa) - ss.begin() + 1;
  set<pair<int, int> > need;
  for (int i = 0; i < n; ++i)
    if (a[i] != b[i]) need.insert(make_pair(b[i], i));
  int ans = 0;
  while (!need.empty()) {
    ++ans;
    auto low = need.lower_bound(make_pair(xa, -1));
    if (low != need.end() && low->first == xa) {
      xa = a[low->second];
      need.erase(low);
    } else {
      low = need.begin();
      swap(xa, a[low->second]);
    }
  }
  cout << ans << '\n';
  cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms"
       << '\n';
  return 0;
}
