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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll n;
    string s,t;
    cin >> n >> s >> t;
    ll kazu_s=0,kazu_t=0;
    rep(i,n){
        if(s[i]=='0') kazu_s++;
        if(t[i]=='0') kazu_t++;
    }
    
    if(kazu_s!=kazu_t){
        cout << -1 << endl;
        return 0;
    }
    
    vector<ll> ss;
    vector<ll> tt;
    
    rep(i,n){
        if(s[i]=='0') ss.push_back(i);
        if(t[i]=='0') tt.push_back(i);
    }
    
    ll ans=0;
    
    rep(i,ss.size()){
        if(ss[i]!=tt[i]) ans++;
    }
    
    cout << ans << endl;

    return 0;
}










#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pvllvll pair <vector <ll>, vector <ll> >
#define ld long double
#define veci vector <int>
#define vecll vector <ll>


const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

void solve() {
    int a[4];
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    int n = 4;
    bool ch = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            if(i == j) continue;
            for(int k = 0; k < n; ++k) {
                if(i == k || j == k) continue;
                for(int z = 0; z < n; ++z) {
                    if(i == z || k == z || j == z) continue;
                    if(a[k] == a[i] + a[j] + a[z] || a[i] + a[j] == a[k] + a[z]) {
                        ch = 1;
                    }
                }
            }
        }
    }
    if(!ch) cout << "No";
    else cout << "Yes";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    ///cin >> T;
    while(T--) solve(), cout << '\n';
    return 0;
}
