#include "bits/stdc++.h"
 
using namespace std;
 
#define              ll              long long
 
#define       forn(i,n)              for(int i=0;i<n;i++)
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()
 
#define            pb                push_back
#define          sz(a)               (int)a.size()
#define         fastio               ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long

ll pw(ll a,ll b){ll r=1;while(b>0){if(b&1)r=(r*a);a=(a*a);b/=2;}return r;}
ll gcd(ll a, ll b) {if(!b)return a;return gcd(b,a % b);}
ll lcm(ll a,ll b){return(a*b)/gcd(a,b);}
ll fact(ll n, ll mod){ll ret=1;for(ll i=1;i<=n;i++)ret=(ret*i)%mod;return ret;}
bool isPrime(ll n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(ll i=5;i*i <= n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}

void solve()
{
	int k;
	cin >> k;
	vector<int> cnt(10,k);
	string a,b;
	cin >> a >> b;
	for(int i = 0; i <4;i++){
		cnt[a[i] - '0']--;
		cnt[b[i] - '0']--; 
	}
	int wins = 0;
	int games= 0 ;
	for(int A = 1;A<=9;A++)
	{
		for(int B = 1;B<=9;B++)
		{
			if(A==B)continue;
			cnt[A]--;
			cnt[B]--;
			if(cnt[A]<0||cnt[B]<0){
				cnt[A]++;
				cnt[B]++;
				continue;
			}
			games += (cnt[A]+1) * (cnt[B] + 1);
			int score_a=0,score_b=0;
			vector<int> v1(10,0),v2(10,0);
			for(int i =0;i < 4;i++){
				v1[a[i] -'0']++;
				v2[b[i]-'0']++;
			}
			v1[A]++;
			v2[B]++;
			for(int i = 1;i<=9;i++){
				score_a+=i * pw(10,v1[i]);
				score_b+=i * pw(10,v2[i]);
			}
			if(score_a>score_b){
				wins+=(cnt[A]+1)*(cnt[B]+1);
			}
			cnt[A]++;
			cnt[B]++;
		}
	}
	for(int A = 1;A<=9;A++)
	{
		if(cnt[A]<2)continue;
		games+=(cnt[A] - 1) * cnt[A];
		int score_a=0,score_b=0;
			vector<int> v1(10,0),v2(10,0);
			for(int i =0;i < 4;i++){
				v1[a[i] -'0']++;
				v2[b[i]-'0']++;
			}
			v1[A]++;
			int B = A;
			v2[B]++;
			for(int i = 1;i<=9;i++){
				score_a+=i * pw(10,v1[i]);
				score_b+=i * pw(10,v2[i]);
			}
			if(score_a>score_b){
				wins+=cnt[A] * (cnt[A] -1);
			}
			cnt[A]++;
			cnt[B]++;
	}
	cout << fixed << setprecision(16) << double(wins)/double(games);
}
 
int32_t main()
{
	//fastio;
    int t = 1;
   	//cin >> t;
    while(t--)
    {
        solve(); 
    }
}
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<set>
#include<algorithm>
#include<string.h>
#include<map>
#define LL long long
#define INF 0x3f3f3f3f
#define mod 100000007
using namespace std;
int k,cnt1[100],cnt2[100];
string s, t;
int main() {
	cin >> k >> s >> t;
	for (int i = 0; i < 4; ++i) {
		cnt1[s[i] - '0']++;
		cnt2[t[i] - '0']++;
	}
	double ans = 0;
	for (int i = 1; i <= 9; ++i) {
		if (cnt1[i] + cnt2[i] >= k)
			continue;
		int x1=0;
		cnt1[i]++;
		for (int k = 1; k <= 9; ++k)
			x1 += k * (int)pow(10, cnt1[k]);
		for (int j = 1; j <= 9; ++j) {
			if (cnt1[j] + cnt2[j] >= k)continue;
			cnt2[j]++;
			int x2 = 0;
			for (int k = 1; k <= 9; ++k)
				x2 += k * (int)pow(10, cnt2[k]);
			if (x1 > x2)
				ans += ((double)k - ((double)cnt1[i] + cnt2[i] - 1-(i==j))) * ((double)k - ((double)cnt1[j] + cnt2[j] - 1-(i==j)) - (i == j));
			cnt2[j]--;
		}
		cnt1[i]--;
	}
	cout << ans / (9.0 * k - 8) / (9.0 * k - 9) << endl;
	return 0;
}