#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
const int N = 100005;
void solve() {
  long long n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  long long c = 0, d = 0;
  for (long long i = 0; i <= n - 1; i++) {
    if (s[i] == '1') c++;
    if (t[i] == '1') d++;
  }
  if (c != d) {
    cout << "-1" << '\n';
    return;
  }
  set<int> odd, even;
  vector<pair<long long, long long> > v;
  for (long long i = 0; i <= n - 1; i++) {
    if (s[i] != t[i]) {
      if (s[i] == '0')
        v.push_back({i, 0});
      else
        v.push_back({i, 1});
    }
  }
  for (long long i = 0; i <= (long long)v.size() - 1; i++) {
    if (v[i].second == 0) {
      if ((long long)even.size()) even.erase(even.begin());
      odd.insert(i);
    } else {
      if ((long long)odd.size()) odd.erase(odd.begin());
      even.insert(i);
    }
  }
  long long ans = (long long)odd.size() + (long long)even.size();
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    solve();
  }
  return 0;
}
