#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
map<int, int> num1, num2;
map<int, int>::iterator ddq;
int n, i, j, k, l, x, y, ans, a[N], b[N], c[N], d[N], cnt;
bool brg[N];
int Abs(int a) { return a > 0 ? a : -a; }
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    num1[a[i]]++;
  }
  for (i = 1; i <= n; ++i) {
    scanf("%d", b + i);
    num2[b[i]]++;
    num1[b[i]];
  }
  x = y = -1;
  for (ddq = num1.begin(); ddq != num1.end(); ddq++)
    if (num2[ddq->first] != num1[ddq->first]) {
      if (Abs(num2[ddq->first] - num1[ddq->first]) >= 2) {
        printf("-1");
        return 0;
      }
      if (num1[ddq->first] > num2[ddq->first]) {
        if (x != -1) {
          printf("-1");
          return 0;
        }
        x = ddq->first;
      } else {
        if (y != -1) {
          printf("-1");
          return 0;
        }
        y = ddq->first;
      }
    }
  if (x != -1) {
    for (i = 1; i <= n; ++i)
      if (a[i] == x && b[i] != y) {
        a[i] = y;
        break;
      }
    if (i > n) {
      for (i = 1; i <= n; ++i)
        if (a[i] == x) {
          a[i] = y;
          ++ans;
          break;
        }
    }
    for (i = 1; i <= n; ++i)
      if (a[i] != b[i]) ++ans;
  } else {
    for (i = 1; i <= n; ++i)
      if (a[i] != b[i]) ++ans;
    if (ans) ++ans;
  }
  printf("%d", ans);
  return 0;
}
