#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pld> vpld;
typedef unordered_map<int, int> mpii;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	cout << fixed;
	cout.precision(17);

	ll k; cin >> k;
	cin.ignore();
	string s; getline(cin, s);
	string t; getline(cin, t);

	vl vec(10, k);
	unordered_map<int, int> S, T;
	for (const auto &a : s) S[a - '0']++, vec[a - '0']--;
	for (const auto &a : t) T[a - '0']++, vec[a - '0']--;

	auto calc = [](auto &cnt) {
		ll ret = 0;
		for (int i = 1; i <= 9; i++) ret += i * powl(10, cnt[i]);
		return ret;
	};

	ll ans = 0;
	for (int i = 1; i <= 10; i++) {
		if (!vec[i]) continue;
		--vec[i];
		for (int j = 1; j <= 10; j++) {
			if (!vec[j]) continue;
			S[i]++;
			T[j]++;
			if (calc(S) > calc(T)) { //ok win
				if (i == j) ans += vec[i] * (vec[i] + 1);
				else ans += (vec[i] + 1) * vec[j];
				//cout << i << " " << j << "\n";
			}
			S[i]--;
			T[j]--;
		}
		++vec[i];
	}

	ld cnt = 9 * k - 8;
	cout << ans / (cnt * (cnt - 1));
}

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */


#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DPoker {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int k; cin >> k;
      string s; cin >> s;
      string t; cin >> t;
      vector<ll> cnts(10);
      vector<ll> cntt(10);
      vector<ll> cnt(10, k);
      rep(i, 4) {
        cnts[s[i]-'0']++;
        cntt[t[i]-'0']++;
        cnt[s[i]-'0']--;
        cnt[t[i]-'0']--;
      }
      ll all = 9*k-8;
      ll allc = all*(all-1);
      double ret = 0;

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

        cnts[i]++;
        ll takahashi = 0;
        for(int a=1; a<=9; a++) {
          ll now = a;
          int tmp = cnts[a];
          while(tmp--) {
            now *= 10;
          }
          takahashi += now;
        }
        cnts[i]--;

        for(int j=1; j<=9; j++) {
          double p = 0;
          if (i==j) {
            ll c = cnt[i]*(cnt[i]-1);
            p = (double)c/(double)allc;
          } else {
            ll c = cnt[i] * cnt[j];
            p = (double)c/(double)allc;
          }

          cntt[j]++;
          ll aoki = 0;
          for(int a=1; a<=9; a++) {
            ll now = a;
            int tmp = cntt[a];
            while(tmp--) {
              now *= 10;
            }
            aoki += now;
          }
          cntt[j]--;

          debug(i, j, takahashi, aoki, p);
          if (takahashi > aoki) {
            ret += p;
          }
        }
      }

      cout << setprecision(10) << fixed;
      cout << ret << endl;
    }
};

signed main() {
  DPoker solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}