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


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

    vector<int> sz,tz;
    rep(i,n){
        if(s[i] == '0') sz.push_back(i);
        if(t[i] == '0') tz.push_back(i);
    }

    int ans = 0;
    if(sz.size() != tz.size()) cout << -1 << endl;
    else{
        rep(i,sz.size()){
            if(sz[i] != tz[i]) ans++;
        }
        cout << ans << endl;
    }
}
#include <iostream>
#include <string>
#include <vector>
int main()
{
    int N;
    std::string S, T;
    std::cin >> N >> S >> T;
    int SS = 0, TT = 0;
    for (int i = N - 1; i >= 0; i--)
    {
        if (S[i] == '1')
        {
            SS++;
        }
    }
    for (int i = N - 1; i >= 0; i--)
    {
        if (T[i] == '1')
        {
            TT++;
        }
    }

    if (SS != TT)
    {
        std::cout << "-1" << std::endl;
        return 0;
    }

    int AT = 0, COUNT = 0, tmp;
    while (AT < N)
    {

        if (S[AT] == T[AT])
        {
            AT++;
            continue;
        }
        else
        {
            if (S[AT] == '1')
            {
                tmp = AT + 1;
                while (S[tmp] == '1')
                {

                    tmp++;
                }
                S[AT] = '0';
                S[tmp] = '1';
                COUNT++;
                AT++;
            }
            else
            {
                tmp = AT + 1;
                while (T[tmp] == '1')
                {

                    tmp++;
                }
                T[AT] = '0';
                T[tmp] = '1';
                COUNT++;
                AT++;
            }
        }
    }

    std::cout << COUNT << std::endl;
    return 0;
}