#include <bits/stdc++.h>
using namespace std;
#define int long long
#define bug(x) cout << #x << "  >>>>>>>  " << x << '\n'
#define _ << " , " <<
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define ii pair<int, int>
#define fi first
#define se second
#define UNTIL(t) while (clock() < (t) * CLOCKS_PER_SEC)
#define SZ(a) (int)a.size()
const int MAX = 400100; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f;
const double EPS = 1e-9;  //10^-9
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int score(string str) {
    int s = 0;
    map<char, int> c;
    for(char a : str) c[a]++;
    for(int i = 1; i < 10; i++) {
        int j = i, e = c[i + '0'];
        while(e--) {
            j *= 10;
        }
        s += j;
    }
    return s;
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
    
    string a, b;
    int k;
    cin >> k >> a >> b;

    map<char, int> cnt;
    for(char i = '0'; i <= '9'; i++)
        cnt[i] = k;

    for(int i = 0; i < 4; i++)
        cnt[a[i]]--;
    for(int i = 0; i < 4; i++)
        cnt[b[i]]--;

    int ganha = 0, tot = 0;

    for(char i = '1'; i <= '9'; i++) {
        for(char j = '1'; j <= '9'; j++) {
            a.back() = i;
            b.back() = j;

            if(!cnt[i] or !cnt[j]) continue;

            int p = cnt[i];
            cnt[i]--;
            p *= cnt[j];
            cnt[i]++;

            if(score(a) > score(b))
                ganha += p;
            tot += p;
        }
    }

    cout << ((1.0 * ganha) / tot) << endl;


    return 0;
}
 
/*
   Before submit:
      Check the corners cases
      Check solution restrictions
 
   For implementation solutions:
      Check the flow of the variables
 
   For intervals problems:
      Think about two pointers
 
   For complete search:
      Think about cuts
 
   If you get WA:
      Reread your code looking for stupid typos
      Try various manual testcases
      Recheck the correctness of your algorithm
      Reread the statement
      Write a straightforward solution, create lots of testcases by yourself, and compare both solutions
      Change the coder (if you're with a team)
      Give up. You may have other tasks to solve.
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
	fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
	ll k;
	cin>>k;
	string s, t;
	cin>>s>>t;
	ll tt = 9*k - 8;
	vlli a, b, ca(10, 0), cb(10, 0);

	forn(i, 0, 4){
		a.pb(s[i]-'0');
		ca[a[i]]++;
		b.pb(t[i]-'0');
		cb[b[i]]++;
	}
	ll c = 0, d = 0;
	a.pb(0);
	b.pb(0);
	forn(i, 1, 10){
		if(ca[i]+cb[i]>k){
			cout<<"0.0000000"<<endl;
			return 0;
		}
	}
	forn(i, 1, 10){
		if(ca[i]+cb[i]==k){
			continue;
		}
		a[4]=i;
		ca[i]++;
		forn(j, 1, 10){
			
			if(cb[j]+ca[j]==k){
				continue;
			}
			
			b[4]=j;
			
			ll sa = 0, sb = 0;
			vlli cca = ca, ccb = cb;
			
			ccb[j]++;
			
			forn(ii, 1, 10){
				sa+=(ii*pow(10, cca[ii]));
				sb+=(ii*pow(10, ccb[ii]));
			}
			if(sa>sb){
				// print(a, 0, 5);
				// print(b, 0, 5);

				if(i == j){
					ll z = k-(ca[i]-1)-cb[i];
					c+=(z*(z-1));
				} else {
					c+=(k-ca[i]+1-cb[i])*(k-cb[j]-ca[j]);
				}

			}
			
		}
		ca[i]--;
	}
	d=(tt*(tt-1));
	// cout<<c<<" "<<d<<endl;
	ld ans = (ld)(c)/(ld)(d);
	cout<<fixed<<setprecision(10)<<ans<<endl;
}