#include<bits/stdc++.h>
#define pi 3.141592653589793238
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void pr(pair<ll,ll> p){
	cout << "[" << p.ff << ", " << p.ss << "]\n";
}
void pr(set<pair<ll,ll>> s){
	for(auto u : s){
		pr(u);
	}
} 
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	fast;
	ll T = 1, i, j;
	
	//cin >> T;
	while (T--) {
		ll n;
		cin >> n;
		string s, t;
		cin >> s >> t;
		ll ca = 0;
		for(auto u : s){
			ca += (u - '0');
		}
		//cout << ca << endl;
		for(auto u : t){
			ca -= (u - '0');
		}
		if(ca != 0){
			cout << -1;
			return 0;
		}
		vector<ll> a, b;
		for(i =0 ; i < n; i++){
			if(s[i] == '0'){
				a.pb(i);
			}
			if(t[i] == '0'){
				b.pb(i);
			}
		}
		ll ans = 0;
		for(i = 0; i < a.size(); i++){
			ans += (a[i] != b[i])
;		}
		cout << ans << endl;
	}
	return 0;
}
#include <bits/stdc++.h>

#define N 500005

using namespace std;

char A[N], B[N];

set<int>st[2];

int C[N], D[N];

int ans = 0;

int main()
{
	int n;
	scanf("%d", &n); 
	scanf("%s", A);
	for (int i = 0; i < n; ++i) if (A[i] == '0') C[++C[0]] = i;
	scanf("%s", B);
	for (int i = 0; i < n; ++i) if (B[i] == '0') D[++D[0]] = i;
	if (C[0] != D[0]) puts("-1");
	else 
	{
		for (int i = 1; i <= C[0]; ++i) if (C[i] != D[i]) ++ans; 
		printf("%d\n", ans);
	} 
}