#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define fore(i_in,a) for (auto& i_in: a)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pq(T) priority_queue<T, vector<T>, greater<T>>
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define fio() cin.tie(nullptr);ios::sync_with_stdio(false);
#define DEBUG_CTN(v) cerr<<#v<<":";for(auto itr=v.begin();itr!=v.end();itr++) cerr<<" "<<*itr; cerr<<endl
template<class T> bool chmax(T &a, const T &b) {if (a<b) { a = b; return true; } return 0;}
template<class T> bool chmin(T &a, const T &b) {if (a>b) { a = b; return true; } return 0;}
template<class T> void print(const T &t) { cout << t << "\n"; }
const ll INF = 1LL << 60;

ll k;
string t, s;

ll f(map<int,ll> ma){
    ll cnt = 0;
    rep1(i,9) cnt += i * pow(10,ma[i]);
    return cnt;
}

int main() {
    fio(); cin>>k>>t>>s;
    map<int, ll> cards, tak, aok;
    rep1(i,9) cards[i] = k;
    rep(i,4) {int tmp = t[i] - '0'; cards[tmp]--; tak[tmp]++;}
    rep(i,4) {int tmp = s[i] - '0'; cards[tmp]--; aok[tmp]++;}
    ll ans = 0;
    rep1(i,9) {
        if(cards[i]>0) tak[i]++;
        else continue;
        rep1(j,9) {
            if(i==j) {
                if(cards[j]>1) aok[j]++;
                else continue;
                if(f(tak) > f(aok)) {
                    ans += cards[i] * (cards[i] - 1);
                }
                aok[j]--;
            } else {
                if(cards[j]>0) aok[j]++;
                else continue;
                if(f(tak) > f(aok)) {
                    ans += cards[i] * cards[j];
                }
                aok[j]--;
            }
        }
        tak[i]--;
    }
    ll denom = (k * 9 - 8) * (k * 9 - 9);
    long double res = ans / (double)denom;
    cerr<< ans << " " << denom<< endl;
    cout << fixed << setprecision(16) << res << "\n";
}

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
# define rep(i,a,b) for(int i=(a); i<=(b); ++i)
# define drep(i,a,b) for(int i=(a); i>=(b); --i)
typedef long long int_;
inline int readint(){
	int a = 0; char c = getchar(), f = 1;
	for(; c<'0'||c>'9'; c=getchar())
		if(c == '-') f = -f;
	for(; '0'<=c&&c<='9'; c=getchar())
		a = (a<<3)+(a<<1)+(c^48);
	return a*f;
}

const int MaxN = 100005;
int cnt[2][10];
char str[10];

int main(){
	int n = readint();
	scanf("%s",str);
	for(int i=0; i<4; ++i)
		++ cnt[0][str[i]-'0'];
	scanf("%s",str);
	for(int i=0; i<4; ++i)
		++ cnt[1][str[i]-'0'];

	int_ ans = 0;
	for(int i=1; i<=9; ++i){
		int_ now = (n-cnt[0][i]-cnt[1][i]);
		++ cnt[0][i]; int sum0 = 0;
		for(int j=1; j<=9; ++j){
			int t = j;
			rep(x,1,cnt[0][j]) t *= 10;
			sum0 += t;
		}
		for(int j=1; j<=9; ++j){
			if(cnt[0][j]+cnt[1][j] >= n)
				continue; // cannot choose
			now *= (n-cnt[0][j]-cnt[1][j]);
			++ cnt[1][j]; int sum1 = 0;
			rep(x,1,9){
				int t = x;
				rep(y,1,cnt[1][x]) t *= 10;
				sum1 += t;
			}
			if(sum0 > sum1)
				ans += now;
			-- cnt[1][j]; // restore
			now /= (n-cnt[0][j]-cnt[1][j]);
		}
		-- cnt[0][i];
	}
	printf("%.15f\n",double(ans)/(9*n-8)/(9*n-9));
	return 0;
}
