#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
char x[N], y[N];
int c[N];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  cin >> (x + 1) >> (y + 1);
  int a = 0, b = 0, cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (x[i] == '1') a++;
    if (y[i] == '1') b++;
    if (x[i] != y[i]) {
      if (x[i] == '0')
        c[++cnt] = 0;
      else
        c[++cnt] = 1;
    }
  }
  if (a != b)
    cout << -1 << endl;
  else {
    int num = 0, mx1 = 0, mx0 = 0;
    for (int i = 1; i <= cnt; i++) {
      if (c[i]) {
        if (mx0)
          mx0--, mx1++;
        else
          num++, mx1++;
      } else {
        if (mx1)
          mx1--, mx0++;
        else
          num++, mx0++;
      }
    }
    cout << num << endl;
  }
}
