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

int main()
{
    int n;
    string s,t;
    cin >> n >> s >> t;
    vector<int> s0;
    vector<int> t0;
    rep(i,n){
        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 = s0.size();
    rep(i,s0.size()){
        if(s0[i]==t0[i])ans--;
    }
    if(ans < 0)ans = 0;
    cout << ans << endl;
    return 0;
}
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

#define rep(i, l, r) for(int i=(l), i##_end_=(r); i<=i##_end_; ++i)
#define drep(i, l, r) for(int i=(l), i##_end_=(r); i>=i##_end_; --i)
#define fi first
#define se second
#define Endl putchar('\n')
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T>inline T fab(T x){ return x<0? -x: x; }
template<class T>inline T readin(T x){
    x=0; int f=0; char c;
    while((c=getchar())<'0' || '9'<c) if(c=='-') f=1;
    for(x=(c^48); '0'<=(c=getchar()) && c<='9'; x=(x<<1)+(x<<3)+(c^48));
    return f? -x: x;
}

const int maxn=500000;

int a[maxn+5], b[maxn+5], n;

vector<int>pa, pb;

inline void input(){
    n=readin(1);
    rep(i, 1, n) scanf("%1d", &a[i]);
    rep(i, 1, n) scanf("%1d", &b[i]);
}

signed main(){
    input();
    rep(i, 1, n) if(!a[i]) pa.push_back(i);
    rep(i, 1, n) if(!b[i]) pb.push_back(i);
    if(pa.size()!=pb.size()) return printf("-1\n"), 0;
    int ans=0;
    for(int i=0, siz=pa.size(); i<siz; ++i)
        if(pa[i]!=pb[i]) ++ans;
    printf("%d\n", ans);
    return 0;
}