#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <cstring>
#include <list>  
#include <cassert>
#include <climits>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
std::mt19937 rnd((int)std::chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

const int MAXN = 500000;

int n;
char s[MAXN + 1];
char t[MAXN + 1];

int solve() {
	vector<int> szero; REP(i, n) if (s[i] == '0') szero.PB(i);
	vector<int> tzero; REP(i, n) if (t[i] == '0') tzero.PB(i);
	if (SZ(szero) != SZ(tzero)) return -1;
	int ret = 0;
	REPSZ(i, szero) if (szero[i] != tzero[i]) ++ret;
	return ret;
}

void run() {
	scanf("%d", &n);
	scanf("%s", s);
	scanf("%s", t);
	printf("%d\n", solve());
}

int main() {
	run();
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll n, ans, s[500050], t[500050], f[2];
vector<int> vs, ts;

int main() {
    scanf("%lld", &n);
    for(int i = 0; i < n; i++) {
        scanf("%1lld", &s[i]);
        f[s[i]]++;
        if(!s[i]) vs.push_back(i);
    }
    for(int i = 0; i < n; i++) {
        scanf("%1lld", &t[i]);
        f[t[i]]--;
        if(!t[i]) ts.push_back(i);
    }
    if(f[0] || f[1]) puts("-1");
    else {
        for(int i = 0; i < vs.size(); i++)
            ans += (vs[i] != ts[i]);
        printf("%lld\n", ans);
    }
    return 0;
}
