#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  vector<int> zero, one;
  for (int i = 0; i < n; i++) {
    if (s[i] != t[i]) (s[i] == '0') ? zero.push_back(i) : one.push_back(i);
  }
  if (zero.size() != one.size()) {
    cout << "-1\n";
  } else {
    int z = 0, o = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '1' && s[i] != t[i]) {
        if (z) z--;
        o++;
      } else if (s[i] == '0' && s[i] != t[i]) {
        if (o) o--;
        z++;
      }
    }
    cout << o + z << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  for (int I = 1; I <= t; I++) {
    solve();
  }
  return 0;
}
