#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
  int n;
  string s,t;
  cin >> n >> s >> t;
  vector<int> a,b;
  for(int i = 0;i < n;i++){
     if(s.at(i) == '0') a.push_back(i);
     if(t.at(i) == '0') b.push_back(i);
  }
  if((int)a.size() != (int)b.size()){
     cout << -1 << endl;
     return 0;
  }
  int res = 0;
  for(int i = 0;i < (int)a.size();i++){
     if(a.at(i) != b.at(i)) res++;
  }
  cout << res << endl;
}
#include <bits/stdc++.h>
constexpr int DEBUG = 0;
using namespace std;
using int64 = long long;

int64 Solve() {
  int n; cin >> n;
  string s0; cin >> s0;
  string s1; cin >> s1;
  vector<int> x0s;
  vector<int> x1s;
  for (int i = 0; i < n; i++) {
    if (s0[i] == '0') {
      x0s.push_back(i);
    }
    if (s1[i] == '0') {
      x1s.push_back(i);
    }
  }
  if (x0s.size() != x1s.size()) return -1;
  int c = 0;
  for (int i = 0; i < x0s.size(); i++) {
    if (x0s[i] != x1s[i]) {
      c++;
    }
  }
  return c;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  cout << Solve() << endl;
}