#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll calc(vector<ll> v) {
  ll count = 0;
  for (int i = 1; i <= 9; i++) {
    count += i * pow(10, v.at(i - 1));
  }
  return count;
}

int main() {
  int K;
  cin >> K;
  //場のカードを管理
  vector<ll> card(9, K);
  string S, T;
  vector<ll> taka(9, 0), ao(9, 0);
  cin >> S >> T;
  for (char c : S) {
    if (c != '#') {
      taka.at(c - '1')++;
      card.at(c - '1')--;
    }
  }
  for (char c : T) {
    if (c != '#') {
      ao.at(c - '1')++;
      card.at(c - '1')--;
    }
  }
  // i:takaの5枚目
  // j:aoの5枚目
  double ans = 0;
  for (int i = 1; i <= 9; i++) {
    vector<ll> card2 = card;
    vector<ll> taka2 = taka;
    if (card2.at(i - 1) == 0) {
      continue;
    }
    card2.at(i - 1)--;
    taka2.at(i - 1)++;
    for (int j = 1; j <= 9; j++) {
      vector<ll> ao2 = ao;
      if (card2.at(j - 1) == 0) {
        continue;
      }
      card2.at(j - 1)--;
      ao2.at(j - 1)++;
      if (calc(taka2) > calc(ao2)) {
        if (i != j) {
          ans += (card2.at(i - 1) + 1) * (card2.at(j - 1) + 1);

        } else {
          ans += (card2.at(i - 1) + 2) * (card2.at(j - 1) + 1);
        }
      }
      card2.at(j - 1)++;
    }
  }
  ans /= (9 * K - 8);
  ans /= (9 * K - 9);
  cout << fixed << setprecision(9);
  cout << ans << endl;
  return 0;
}
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define all(v) v.begin(), v.end()
#define rep(i, begin, end) for(int i = begin; i < (int)(end); i++)
#define contains(v, x) (find(all(v), x) != v.end())
template<class T> bool chmin(T& a, T b){ if (a > b){ a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b){ if (a < b){ a = b; return true; } return false; }
template<class T> T roundup(T a, T b){ return (a + b - 1) / b; }
const double PI = 3.14159265359;
const vector<int> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
const vector<int> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};
using ll = long long;
struct Edge{ int to; ll cost; Edge(int to, ll cost) : to(to), cost(cost) {} };
const ll MOD = (ll)1e9 + 7;
const ll INF = (ll)1e9;
using P = pair<ll, int>;
using Graph = vector<vector<int>>;
/*#include <atcoder/all>
using namespace atcoder;
using mint = modint;*/

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    //mint::set_mod(MOD);
    
    int k;
    string s, t;
    cin >> k >> s >> t;
    
    vector<int> cnta(10), cntb(10);
    rep(i, 1, 10) cnta[i] = count(all(s), '0' + i);
    rep(i, 1, 10) cntb[i] = count(all(t), '0' + i);
    
    
    vector<ll> rem(10, k);
    for(auto i : s) if(i > '0') rem[i - '0']--;
    for(auto i : t) if(i > '0') rem[i - '0']--;
    
    double ans = 0;
    rep(a, 1, 10) rep(b, 1, 10){
        if(rem[a] < 1 || rem[b] < 1) continue;
        else if(a == b) if(rem[a] < 2) continue;
        vector<int> tempa = cnta, tempb = cntb;
        tempa[a]++, tempb[b]++;
        ll sa = 0, sb = 0;
        
        rep(i, 1, 10){
            sa += i * (ll)pow(10, tempa[i]);
            sb += i * (ll)pow(10, tempb[i]);
        }
        
        if(sa > sb){
            if(a != b) ans += rem[a] * rem[b];
            else ans += rem[a] * (rem[a] - 1);
        }
    }
    cout << fixed << setprecision(10) << ans / (double)(9 * k - 8) / (9 * k - 9) << endl;
}
