#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long q;
  q = 1;
  while (q--) {
    long long n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    vector<bool> mm(n, 0);
    long long type1 = 0;
    long long type2 = 0;
    long long ans = 0;
    long long count = 0;
    for (long long i = 0; i < n; ++i)
      if (a[i] != b[i]) {
        count++;
        if (a[i] == '1') {
          if (type2 != 0) type2--;
          type1++;
        } else {
          if (type1 != 0) type1--;
          type2++;
        }
      }
    if (count % 2)
      cout << -1 << endl;
    else
      cout << type1 + type2 << endl;
  }
  return 0;
}
