#include<bits/stdc++.h>
#define int ll
#define sz(x) int((x).size())
#define all(x) (x).begin(),(x).end()
#define x first
#define y second
using namespace std;
using ll = long long;
using pi = pair<int,int>;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int minf = 0xc0c0c0c0c0c0c0c0;



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

    int n; string s,t; cin>>n>>s>>t;
    if (count(all(s), '0') != count(all(t), '0')) {
        cout<<-1<<'\n';
        return 0;
    }

    int _01 = 0, _10 = 0;
    int res = 0;
    for (int i=0; i<n; i++) {
        if (s[i] == '0') {
            // 00
            if (t[i] == '0') {
                if (_10 || _01) ++res;
            }
            // 01
            else {
                if (_10) {
                    ++res;
                    --_10;
                }
                else {
                    ++_01;
                }
            }
        }
        else {
            // 10
            if (t[i] == '0') {
                if (_01) {
                    ++res;
                    --_01;
                }
                else {
                    ++_10;
                }
            }
        }
    }
    assert(_01 == 0 && _10 == 0);
    cout<<res<<'\n';


    return 0;
}
#include "bits/stdc++.h"
using namespace std;
using li = long long;
const char newl = '\n';
template <class T> vector<vector<T>> vv(const unsigned int n, const unsigned int m, const T x) { return vector<vector<T>>(n, vector<T>(m, x)); }
template <class T> vector<vector<vector<T>>> vvv(const unsigned int n, const unsigned int m, const unsigned int k, const T x) { return vector<vector<vector<T>>>(n, vv(m, k, x)); }
template <class T> bool contains(const set<T>& s, const T& v) { return s.find(v) != s.end(); }
template <class T> bool contains(const unordered_set<T>& s, const T& v) { return s.find(v) != s.end(); }
template <class K, class V> bool contains_key(const map<K, V>& m, const K& v) { return m.find(v) != m.end(); }

auto memo = vvv(101, 101, 101, (double)-1.);
double recur(li a, li b, li c) {
    if (a >= 100 || b >= 100 || c >= 100) {
        return 0;
    }
    double &ans = memo[a][b][c];
    if (ans != -1.) {
        return ans;
    }
    double sum = a + b + c;
    ans = 1;
    ans += recur(a + 1, b, c) * a / sum;
    ans += recur(a, b + 1, c) * b / sum;
    ans += recur(a, b, c + 1) * c / sum;
    return ans;
}

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

    li a, b, c;
    cin >> a >> b >> c;
    cout.precision(12);
    cout << recur(a, b, c) << endl;

    return 0;
}