#include <bits/stdc++.h>
using namespace std;
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) {
  return (b == 0LL ? a : gcd(b, a % b));
}
long long exp(long long a, long long b, long long m) {
  if (b == 0LL) return 1LL;
  if (b == 1LL) return mod(a, m);
  long long k = mod(exp(a, b / 2, m), m);
  if (b & 1LL) {
    return mod(a * mod(k * k, m), m);
  } else
    return mod(k * k, m);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  vector<long long> cnt(2);
  for (long long i = 0; i < n; i++) {
    cnt[s[i] - '0']++;
  }
  for (long long i = 0; i < n; i++) cnt[t[i] - '0']--;
  if (cnt[0] != 0 or cnt[1] != 0) {
    cout << -1 << "\n";
    return 0;
  }
  long long t1 = 0, t2 = 0;
  long long turn = 0;
  long long res = 0;
  vector<long long> v;
  long long zer = 0, um = 0;
  for (long long i = 0; i < n; i++) {
    if (s[i] == t[i]) continue;
    if (s[i] == '0') {
      if (um)
        um--, zer++;
      else
        zer++, res++;
    } else {
      if (zer)
        zer--, um++;
      else
        res++, um++;
    }
  }
  cout << res << "\n";
}
