#include <bits/stdc++.h>
using namespace std;

const int maxN = 1e6 + 10;

int n;
char s[maxN + 1];

vector<int> v0, v1;

int main()
{
	scanf("%d", &n);
	scanf("%s", s + 1);
	for(int i = 1; i <= n; i++)
		if(s[i] == '0') v0.push_back(i);
	scanf("%s", s + 1);
	for(int i = 1; i <= n; i++)
		if(s[i] == '0') v1.push_back(i);
	
	if(v0.size() != v1.size()) return puts("-1"), 0;

	int ans = 0;
	for(int i = 0; i < v0.size(); i++) ans += (v0[i] != v1[i]);

	printf("%d\n", ans);
	return 0;
}

#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define F(i,n) for (int i = 0; i < n; ++i)
#define F1(i,n) for (int i = 1; i <= n; ++i)
#define dbg(x) cerr << #x << " = " << x << endl
#define dbgg(x) cerr << #x << " = " << x << ' '
#define T(x) x[pool]
#define mineq(x,y) { if ((x) > (y)) (x) = (y); }
#define maxeq(x,y) { if ((x) < (y)) (x) = (y); }
#define MEOW cout << "meowwwww" << '\n'; system("pause");
#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c)
{
	s << "[ "; for (auto it : c) s << it << " "; s << "\b]\n";
	return s;
}

template<typename T>
ostream& operator <<(ostream &s, const pair<int, T> &c)
{
	s << "[ "; cout << c.fi << " , " << c.se << " ] ";
	return s;
}

int n;
string a, b;
vector<char> p, q;
vi x, y;

void input()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	cin >> a >> b;
}

void solve()
{
	int s = 0;
	F (i, n)
		if (a[i] == '1') ++s;
	F (i, n)
		if (b[i] == '1') --s;
	if (s) { cout << "-1\n"; return; }
	int ans = 0;
	a = ' ' + a;
	b = ' ' + b;
	int x = 0, y = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (x > 0 && a[i] == '0') { a[i] = '1'; --x; }
		if (y > 0 && b[i] == '0') { b[i] = '1'; --y; }
		if (a[i] != b[i])
		{
			if (a[i] == '1') { a[i] = '0'; ++x; }
			if (b[i] == '1') { b[i] = '0'; ++y; }
			++ans;
		}
	}
	cout << ans << '\n';
}

main()
{
	input();
	solve();
}
