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

int n;
string s,t;

bool bo(){
  int s1=0,t1=0;
  rep(i,n){
    if(s[i]=='1') s1++;
    if(t[i]=='1') t1++;
  }
  return (s1==t1);
}

int main(){
  cin >> n >> s >> t;
  vector<int> s1(0);
  vector<int> t1(0);
  rep(i,n){
    if(s[i]=='0') s1.push_back(i);
    if(t[i]=='0') t1.push_back(i);
  }
  int sn=s1.size();
  int tn=t1.size();
  if(sn!=tn) cout << -1 << endl;
  else{
    int ans=0;
    rep(i,sn){
      if(s1[i]!=t1[i]) ans++;
    }
    cout << ans << endl;
  }
}
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int K; string S, T; cin >> K >> S >> T;
    vector<ll> cards(10, K), scards(10, 0), tcards(10, 0);
    for (auto c : S) {
        if (c == '#') break;
        cards[c - '0']--;
        scards[c - '0']++;
    }
    for (auto c : T) {
        if (c == '#') break;
        cards[c - '0']--;
        tcards[c - '0']++;
    }


    vector<ll> multiples(10, 1);
    REP(i, 1, 10) multiples[i] = multiples[i - 1] * 10;

    ll s = 0, t = 0;
    REP(i, 1, 10) {
        s += multiples[scards[i]] * i;
        t += multiples[tcards[i]] * i;
    }
    // cout << "### base : " << s << ", " << t << endl;

    ll win = 0, lose = 0;
    REP(i, 1, 10) {
        if (!cards[i]) continue;
        cards[i]--;
        s -= multiples[scards[i]] * i;
        s += multiples[scards[i] + 1] * i;
        // cout << "# i : " << i << ", s : " << s << endl;
        REP(j, 1, 10) {
            if (!cards[j]) continue;
            t -= multiples[tcards[j]] * j;
            t += multiples[tcards[j] + 1] * j;
            // cout << "# j : " << j << ", t : " << t << endl;
            if (s > t) {
                win += (cards[i] + 1) * cards[j];
            } else {
                lose += (cards[i] + 1) * cards[j];
            }
            t -= multiples[tcards[j] + 1] * j;
            t += multiples[tcards[j]] * j;
        }
        s -= multiples[scards[i] + 1] * i;
        s += multiples[scards[i]] * i;
        cards[i]++;
    }
    // cout << win << ", " << lose << endl;
    cout << fixed << setprecision(15);
    cout << (long double)(win) / (win + lose) << endl; 
    return 0;
}
