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

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

    vector<int> s0, t0;
    for (int i = 0; i < n; i++) {
        if (s[i] == '0') {
            s0.push_back(i);
        }
        if (t[i] == '0') {
            t0.push_back(i);
        }
    }

    if (s0.size() != t0.size()) {
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;

    for (int i = 0; i < s0.size(); i++) {
        if (s0[i] != t0[i]) {
            ans++;
        }
    }

    cout << ans << endl;
}
    #include<bits/stdc++.h>
    using namespace std;
    #define endl "\n"
    #define mp make_pair
    #define ll long long


int gcd(int a,int b){
    if(b==0)
        return a;

    int hcf=gcd(b,a%b);

    return hcf;
}
int main(){

    ios_base::sync_with_stdio(false);cin.tie(NULL);
   /* // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    */
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)
        cout<<c<<endl;
    else if(a==c)
        cout<<b<<endl;
    else if(b==c)
        cout<<a<<endl;
    else
        cout<<0<<endl;
}   
