#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long fastPow(long long base, long long exp, long long mod) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = ((res % mod) * (base % mod)) % mod;
    base = ((base % mod) * (base % mod)) % mod;
    exp /= 2;
  }
  return res % mod;
}
void solve() {
  long long n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  long long c0 = 0, c1 = 0;
  for (long long i = 0; i < n; i++) {
    if (s[i] == '0')
      c0++;
    else
      c1++;
  }
  for (long long i = 0; i < n; i++) {
    if (t[i] == '0')
      c0--;
    else
      c1--;
  }
  if (c0 != 0 || c1 != 0) {
    cout << "-1\n";
    return;
  }
  c0 = 0, c1 = 0;
  for (long long i = 0; i < n; i++) {
    if (s[i] == '1' && t[i] == '0') {
      if (c0) c0--;
      c1++;
    } else if (s[i] == '0' && t[i] == '1') {
      if (c1) c1--;
      c0++;
    }
  }
  cout << c0 + c1 << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long tc = 1;
  while (tc--) {
    solve();
  }
  return 0;
}
