#include <bits/stdc++.h>
using namespace std;
int main(int argc) {
  int n;
  cin >> n;
  vector<int> t1, t2, t3;
  int t;
  for (int i = 0; i < n; ++i) {
    cin >> t;
    t1.push_back(t);
    t3.push_back(t);
  }
  for (int i = 0; i < n; ++i) {
    cin >> t;
    t2.push_back(t);
    t3.push_back(t);
  }
  sort(t3.begin(), t3.end());
  vector<int> t4;
  for (int i = 0; i < 2 * n; i += 2) {
    if (t3[i] != t3[i + 1]) {
      cout << "-1" << endl;
      return 0;
    }
    t4.push_back(t3[i]);
  }
  sort(t1.begin(), t1.end());
  int i = 0, j = 0;
  int count = 0;
  while (i < n && j < n) {
    if (t1[i] == t4[j]) {
      ++i;
      ++j;
      ++count;
    } else if (t1[i] > t4[j]) {
      ++j;
    } else {
      ++i;
    }
  }
  cout << min(count, n - count) << endl;
  return 0;
}
