#include <bits/stdc++.h>
using namespace std;
long long int llog(long long int n) {
  long long int cnt = 0;
  while (n % 2 == 0) {
    n /= 2;
    cnt++;
  }
  return cnt;
}
long long int power(long long int a, long long int b) {
  long long int ans = 1;
  while (b != 0) {
    ans *= a;
    b--;
  }
  return ans;
}
void solve() {
  int n, ones = 0, zeros = 0;
  string s, t;
  cin >> n >> s >> t;
  for (int i = 0; i < n; i++) {
    ones += (s[i] == '1');
    zeros += (t[i] == '1');
  }
  if (ones != zeros) {
    cout << "-1\n";
    return;
  }
  if (s == t) {
    cout << "0\n";
    return;
  }
  ones = zeros = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1' && t[i] == '0') {
      if (ones != 0) ones--;
      zeros++;
    } else if (s[i] == '0' && t[i] == '1') {
      if (zeros != 0) zeros--;
      ones++;
    }
  }
  cout << ones + zeros << endl;
}
int main() {
  int t;
  t = 1;
  for (int q = 0; q < t; q++) {
    solve();
  }
  return 0;
}
