#include <bits/stdc++.h>
using namespace std;
#define TC 0
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

template <typename T>
vector<T> readArr(int n) {
    vector <T> v(n);
    for (auto &it : v)
        cin >> it;
    return v;
}

void init() {
    ;
}

void solve() {
    int k; cin >> k;
    string s, t; cin >> s >> t;
    
    vector <ll> cards(10, k);
    
    for (char ch: s)
        if (ch != '#')
            cards[ch-'0']--;
        
    for (char ch: t)
        if (ch != '#')
            cards[ch-'0']--;
    
    ll scoreA = 0, scoreB = 0;
    
    vector <int> s1(10), s2(10);
    for (int i=0; i<4; i++) {
        s1[s[i]-'0']++;
        s2[t[i]-'0']++;
    }
    
   // string test = "11222
        
    for (int i=1; i<=9; i++) {
       // cout << deb(i) deb(s1[i]) deb(s2[i]) << "\n";
        scoreA += (i * pow(10, s1[i]));
        scoreB += (i * pow(10, s2[i]));
    }
    //cout << scoreA <<" " << scoreB << "\n";
        ll num = 0;
        ll d = 0;
    for (int i=1; i<=9; i++) {
        for (int j=1; j<=9; j++) {
            if (i == j) {
                if (cards[i] < 2)
                    continue;
            } else if (cards[i] == 0 || cards[j] == 0) {
                continue;
            }  
        
            ll ct = cards[i] * cards[j];
            if (i == j)
                ct = (cards[i]*(cards[i]-1));
            d += ct;
            ll ns1 = scoreA;
            ns1 -= (i*pow(10, s1[i]));
            ns1 += (i*pow(10, s1[i]+1));
            
            ll ns2 = scoreB;
            ns2 -= (j*pow(10, s2[j]));
            ns2 += (j*pow(10, s2[j]+1));
            
            //cout << deb(i) deb(j)  deb(ns1)  deb(ns2) << "\n";
            if (ns1 > ns2) {
                num += ct;
            }
        }
    }
    
   //cout << num  << " "  << " " << d << "\n";
    double res = (double)num / (double)d;
    printf("%.14f\n", res);
}

int main() {
    IOS
    init();
    int t = 1;
    if (TC)
        cin >> t;

    while (t--) {
        solve();
    }
}

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint K;
  string S, T;
  cin >> K >> S >> T;
  vector<lint> cnt(10, K);
  vector<lint> ta(10);
  vector<lint> ao(10);
  REP(i, 4) {
    ta[S[i] - '0']++;
    cnt[S[i] - '0']--;
    ao[T[i] - '0']++;
    cnt[T[i] - '0']--;
  }
  lint bunsi = 0;
  lint bunbo = 0;
  FOR(i, 1, 10) FOR(j, 1, 10) {
    lint tascore = 0;
    lint aoscore = 0;
    FOR(k, 1, 10) {
      lint tmp = k;
      REP(j, ta[k]) tmp *= 10;
      if(k == i) tmp *= 10;
      tascore += tmp;
    }
    FOR(k, 1, 10) {
      lint tmp = k;
      REP(j, ao[k]) tmp *= 10;
      if(k == j) tmp *= 10;
      aoscore += tmp;
    }
    lint pattern = cnt[i] * cnt[j];
    if(i == j) pattern = cnt[i] * (cnt[j] - 1);
    if(tascore > aoscore) bunsi += pattern;
    bunbo += pattern;
  }
  cout << fixed << setprecision(10) << (double)bunsi / (double)bunbo << "\n";
}