#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  string s, t;
  cin >> s >> t;
  vector<int> a;
  for (int i = 0; i < n; i++)
    if (s[i] != t[i]) a.push_back(s[i] - '0');
  int cnt0 = 0, cnt1 = 0;
  for (int i = 0; i < (int)a.size(); i++)
    if (a[i] == 0)
      cnt0++;
    else
      cnt1++;
  if (cnt0 != cnt1) {
    printf("-1");
    return 0;
  }
  set<int> t0, t1;
  for (int i = 0; i < (int)a.size(); i++) {
    if (a[i] == 0) {
      if (t1.empty()) {
        t0.insert(i);
        continue;
      }
      t1.erase(*t1.begin());
      t0.insert(i);
    } else {
      if (t0.empty()) {
        t1.insert(i);
        continue;
      }
      t0.erase(*t0.begin());
      t1.insert(i);
    }
  }
  printf("%d", (int)t0.size() + (int)t1.size());
}
