#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,int>;
template<class T> using V = vector<T>;
template<typename T> using posteriority_queue = priority_queue<T,vector<T>,greater<T>>;
#define rep(i,n) for (int i = 0; i < (int)(n) ; i++)
#define rep2(i,a,b) for (int i = (a); i < (int)(b); i++)
#define repR(i,n) for (int i = (int)(n)-1; i >= 0; i--)
#define repR2(i,a,b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define pb push_back
#define SIZE(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define UNIQUE(a) a.erase(unique(all(a)),a.end());
#define debug(x) cout<<(#x)<<" is : "<<(x)<<endl;
#define debugc(vec) {cout<<(#vec)<<" is below; -------"<<endl;for(auto elements:(vec))cout<<elements<<" ";cout<<endl<<"------------------"<<endl;}
inline string rev(string s) {string t(s.rbegin(), s.rend()); return t;}
template<class T> inline bool chmin(T &a, T b) { if(a>b) {a=b; return 1;} return 0;}
template<class T> inline bool chmax(T &a, T b) { if(a<b) {a=b; return 1;} return 0;}
const char ENDL = '\n';
const ll INF = (1LL<<30)-1;
const ll INFLL = (1LL<<62)-1;
const ld PI = 3.14159265358979323846L;
const ld EPS = 1e-8;
int main() {
    cout << fixed << setprecision(15);
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int a,b,c; cin>>a>>b>>c;
    if(a==b) cout<<c<<endl;
    else if(b==c) cout<<a<<endl;
    else if(c==a) cout<<b<<endl;
    else cout << 0 << endl;
}
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
	#include "dbg.h"
#else
	#define out(...) 
#endif

void solve () {
    int n;
    string s, t;
    cin >> n >> s >> t;
    vector<int> idxs, idxt;

    for (int i = 0; i < n; ++i) {
        if (s[i] == '0') idxs.push_back (i);
        if (t[i] == '0') idxt.push_back (i);
    }

    if ((int) idxs.size() != (int) idxt.size()) {
        cout << -1 << '\n';
        return ;
    }
    int cnt = 0;

    for (int i = 0; i < (int) idxt.size(); ++i) {
        if (idxt[i] != idxs[i])
            ++cnt;
    }
    cout << cnt << '\n';
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int tc = 1;
	// cin >> tc;

	for (int i = 1; i <= tc; ++i) 
		solve ();
}