#include <bits/stdc++.h>
using namespace std;
template <class T>
void rd(T &l) {
  l = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = 0;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    l = l * 10 + (ch ^ '0');
    ch = getchar();
  }
  l = (f ? l : -l);
}
char s[1000005], t[1000005];
int main() {
  int n, ans1 = 0, ans2 = 0;
  rd(n);
  scanf("%s", s + 1);
  scanf("%s", t + 1);
  for (int i = 1; i <= n; ++i) {
    if (s[i] == '0') ++ans1;
    if (t[i] == '0') ++ans2;
  }
  if (ans1 != ans2) {
    puts("-1");
    return 0;
  }
  ans1 = ans2 = 0;
  for (int i = 1; i <= n; ++i)
    if (s[i] != t[i]) {
      if (s[i] == '0') {
        if (!ans1)
          ++ans2;
        else
          --ans1, ++ans2;
      } else {
        if (!ans2)
          ++ans1;
        else
          --ans2, ++ans1;
      }
    }
  printf("%d\n", ans1 + ans2);
  return 0;
}
