#include <bits/stdc++.h>
using namespace std;
int m[3][3];
string s, s1;
int main() {
  int n;
  cin >> n;
  cin >> s >> s1;
  int r = 0, re = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') r++;
  }
  for (int i = 0; i < n; i++) {
    if (s1[i] == '1') re++;
  }
  if (r != re) {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == s1[i]) continue;
    if (s[i] == '1') {
      if (m[0][1] > 0) {
        m[0][1]--;
        m[1][0]++;
      } else if (m[0][0] > 0) {
        m[0][0]--;
        m[1][1]++;
      } else {
        m[1][1]++;
      }
    } else if (s[i] == '0') {
      if (m[1][1] > 0) {
        m[1][1]--;
        m[0][0]++;
      } else if (m[1][0] > 0) {
        m[1][0]--;
        m[0][1]++;
      } else {
        m[0][1]++;
      }
    }
  }
  int g = 0;
  re = m[0][1] + m[1][1];
  g += re / 2 + (re % 2);
  re = m[1][0] + m[0][0];
  g += re;
  cout << g;
}
