#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, m, ans;
int cnt0, cnt1;
char a[N], b[N];
int c[N];
int main() {
  cin >> n;
  int cnt1 = 0, cnt2 = 0;
  scanf("%s", a + 1);
  scanf("%s", b + 1);
  for (int i = 1; i <= n; i++)
    if (a[i] == '1') cnt1++;
  for (int i = 1; i <= n; i++)
    if (b[i] == '1') cnt2++;
  if (cnt1 != cnt2) {
    cout << -1;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] != b[i]) c[++m] = a[i] - 48;
  }
  cnt0 = cnt1 = 0;
  for (int i = 1; i <= m; i++) {
    if (c[i] == 1) {
      if (cnt0 > 0)
        cnt0--;
      else
        ans++;
      cnt1++;
    } else {
      if (cnt1 > 0)
        cnt1--;
      else
        ans++;
      cnt0++;
    }
  }
  cout << ans;
  return 0;
}
