#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if(a != b && a != c && b != c) {
		cout << "0";
	}
	else if(a == b && b == c &&  a == c) {
		cout << a;
	}
	else if(a == b && a != c) {
		cout << c;
	}
	else if(a == c && a != b) {
		cout << b;
	}
	else if(c == b && a != b) {
		cout << a;
	}
	return 0;
}
#include<bits/stdc++.h>
using namespace std;

#define INF 1234567890
#define ll long long

int N;
string s, t;
vector<int> S, T;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);
	cin >> N >> s >> t;
	int sz = 0, so = 0, tz = 0, to = 0;
	for(int i=0; i<N; i++)
	{
		if (s[i] == '0') sz++, S.push_back(i);
		else so++;

		if (t[i] == '0') tz++, T.push_back(i);
		else to++;
	}
	if (sz != tz) { cout << -1 << "\n"; return 0; }
	int Z = sz;

	int res = 0;
	for(int i=0; i<Z; i++)
	{
		if (S[i] != T[i])
			res++;
	}
	cout << res << "\n";
	return 0;
}