#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	int n;
	string s, t;
	cin>>n>>s>>t;

	vector<int> si, ti;
	rep(i, n) if(s[i]=='0') si.push_back(i);
	rep(i, n) if(t[i]=='0') ti.push_back(i);

	int ans=-1;
	if(si.size()==ti.size()){
		int cnt=0;
		rep(i, si.size()) if(si[i]!=ti[i]) cnt++;
		ans=cnt;
	}

	cout<<ans<<endl;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
 
void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
 
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
 
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
 
#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

int main() {
	int N;
	string S, T;
	cin >> N >> S >> T;

	string SS = S, TT = T;
	sort(SS.begin(), SS.end());
	sort(TT.begin(), TT.end());

	if(SS != TT) {
		cout << -1 << '\n';
		return 0;
	}

	int res = 0;
	// int excess_zero = 0, excess_one = 0;

	// int p = 0;
	// for(int i = 0; i < N; i++) {
	// 	if(T[i] == '0' && excess_zero > 0)
	// 		--excess_zero;

	// 	else if(T[i] == '1' && excess_one > 0)
	// 		--excess_one;

	// 	else {
	// 		while(S[p] != T[i]) {
	// 			if(S[p] == '0')
	// 				excess_zero++;
	// 			else
	// 				excess_one++;
	// 			p++;
	// 		}

	// 		debug(i, p, excess_zero, excess_one);
	// 		if(excess_zero)
	// 			res += excess_zero;
	// 		if(excess_one)
	// 			res += 1;
	// 		p++;
	// 	}
	// }

	vector<int> a, b;
	for(int i = 0; i < N; i++) {
		if(S[i] == '0')
			a.push_back(i);
		if(T[i] == '0')
			b.push_back(i);
	}

	for(int i = 0; i < (int) a.size(); i++) {
		if(a[i] != b[i])
			res++;
	}

	cout << res << '\n';
}