#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, end0 = 0, end1 = 0, ans = 0, zs1 = 0, zs2 = 0, i;
  string s1, s2;
  cin >> n;
  cin >> s1 >> s2;
  for (i = 0; i < n; i++) {
    if (s1[i] == '0') zs1++;
    if (s2[i] == '0') zs2++;
  }
  if (zs1 != zs2) {
    cout << "-1\n";
    return 0;
  }
  for (i = 0; i < n; i++) {
    if (s1[i] != s2[i]) {
      if (s1[i] == '0') {
        if (end1 == 0) {
          end0++;
          ans++;
        } else {
          end1--;
          end0++;
        }
      } else {
        if (end0 == 0) {
          end1++;
          ans++;
        } else {
          end0--;
          end1++;
        }
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
