#include<iostream>
#include<stdio.h>
#include<iomanip>
using namespace std;
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>


long long int pw(int x,int n)
{
    long long int res=1;

    while(n>0)
    {
        if(n%2==0)
        {
            n=n/2;
            x=x*x;
        }

        else
        {
            n=n-1;
            res=res*x;
        }
    }

    return res;



}

int main()
{
    long long int k,i,j;
    cin>>k;

    long long int cnt[10]={0},cntt[10]={0},cnta[10]={0};

    for(i=1;i<=9;i=i+1)
    {
        cnt[i]=k;
    }


    string s,t;
    cin>>s>>t;

    for(i=0;i<s.length()-1;i=i+1)
    {
        cnt[s[i]-'0']--;
        cntt[s[i]-'0']++;
    }

    for(i=0;i<t.length()-1;i=i+1)
    {
        cnt[t[i]-'0']--;
        cnta[t[i]-'0']++;
    }


    long long int sumt=0,suma=0;

    for(i=1;i<=9;i=i+1)
    {
        sumt=sumt+(i*pw(10,cntt[i]));
        suma=suma+(i*pw(10,cnta[i]));
    }



    long long int  prob=0;

    long long int total=(9*k-8);


    for(i=1; i<=9; i=i+1)
    {
        for(j=1; j<=9; j=j+1)
        {

                long long int csumt=sumt-(i*pw(10,cntt[i]))+(i*pw(10,cntt[i]+1));
                long long int csuma=suma-(j*pw(10,cnta[j]))+(j*pw(10,cnta[j]+1));

                if(csumt>csuma && i!=j)
                {
                    prob=prob+(cnt[j])*(cnt[i]);


                }

                else if(csumt>csuma && i==j)
                {
                    prob=prob+(cnt[i])*(cnt[i]-1);
                }



        }
    }


    cout<<(double)prob/total/(total-1) <<endl;

}

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <array>
//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef tuple<ll, ll, ll> tl3;
typedef tuple<double, ll, ll> tdl2;



//typedef modint998244353 mint;

const int BIG_NUM = 1e9 + 5;
const ll INF = 1000000000000000000 + 5;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
//const int MOD = 10007;
const double EPS = 1e-7;
const int MAX = 24 * 60 * 60;

ll pow10(ll p) {
	ll a = 1;
	for (int i = 0; i < p; i++) {
		a *= 10;
	}
	return a;
}

int main() {
	ll k;
	cin >> k;
	vector<string> s(2);
	for (int i = 0; i < 2; i++) {
		cin >> s[i];
	}

	vector<int> t(10);
	vector<int> a(10);
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 2; j++) {
			int num = s[j][i] - '0';
			if (j == 0) {
				t[num]++;
			}
			else {
				a[num]++;
			}
		}
	}


	ll w = 0;
	ll sum = 0;
	for (int i = 1; i < 10; i++) {
		vector<int> ta(t);
		ta[i]++;


		for (int j = 1; j < 10; j++) {
			vector<int> ao(a);
			ao[j]++;

			bool canConsist = true;
			for (int l = 0; l < 10; l++) {
				if (ta[l] + ao[l] > k) {
					canConsist = false;
				}
			}
			if (!canConsist) {
				continue;
			}

			ll sc = 0;
			for (int l = 0; l < 10; l++) {
				ll st = l * pow10(ta[l]);

				sc += st;


				ll sa = l * pow10(ao[l]);

				sc -= sa;



			}

			ll p = 1;
			if (i != j) {
				p *= (k - t[i] - a[i]);
				p *= (k - t[j] - a[j]);
			}
			else {
				ll r = k - t[i] - a[i];
				p *= r * (r - 1);
			}

			sum += p;
			if (sc > 0) {
				w += p;

			}
		}
	}

	cout << setprecision(20) << 1.0 * w / sum << endl;
}