#include <bits/stdc++.h>
using namespace std;
using db = double;
bool win(string s, string t) {
  int num[2][10];
  for (int i = 0; i < 2; i ++) {
    for (int j = 0; j < 10; j ++) {
      num[i][j] = 0;
    }
  }
  for (int i = 0; i < 5; i ++) {
    int kj = (int)s[i] - (int)'0';
    num[0][kj] ++;
  }
  for (int j = 0; j < 5; j ++) {
    int kj = (int)t[j] - (int)'0';
    num[1][kj] ++;
  }
  int X[2];
  for (int i = 0; i < 2; i ++) {
    X[i] = 0;
    for (int j = 0; j < 10; j ++) {
      int pk = j;
      for (int k = 0; k < num[i][j]; k ++) {
        pk *= 10;
      }
      X[i] += pk;
    }
  }
  //cout << s << ' ' << t << ' ' << X[0] << ' ' << X[1] << endl;
  return X[0] > X[1];
}
int main () {
  long long K;
  cin >> K;
  long long numb[10];
  for (int i = 1; i < 10; i ++) {
    numb[i] = K;
  }
  long long k_ = K;
  k_ *= 9;
  long long bo = ((k_ - 8) * (k_ - 9)) / 2;
  //cout << bo << endl;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < 4; i ++) {
    int kj = (int)s[i] - (int)'0';
    numb[kj] --;
  }
  for (int i = 0; i < 4; i ++) {
    int kj = (int)t[i] - (int)'0';
    numb[kj] --;
  }
  db ans = 0;
  long long ansn = 0;
  string key = "0123456789";
  for (int x = 1; x < 10; x ++) {
    for (int y = 1; y < 10; y ++) {
      s[4] = key[x];
      t[4] = key[y];
      if (win(s, t)) {
        long long si = numb[x] * numb[y];
        if (x == y) {
          si -= numb[x];
        }
        ansn += si;
        //cout << x << ' ' << y << ' ' << ansn << endl;
      }
    }
  }
  //cout << ansn << endl;
  ans = (db)ansn / bo;
  cout << setprecision(20) << ans / 2 << endl;
}
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int n, t1[10], t2[10], sum1, sum2;
string a, b;
double res;
int main() {
  cin >> n >> a >> b;
  REP(i, 4) t1[a[i]-'0']++, t2[b[i]-'0']++;
  REP(i, 10) sum1 += i*pow(10, t1[i]), sum2 += i*pow(10, t2[i]);
  for (int i=1; i<10; i++) for (int j=1; j<10; j++) {
    int A = sum1+9*i*pow(10,t1[i]);
    int T = sum2+9*j*pow(10,t2[j]);
    if (A>T) res += 1.0*(n-t1[i]-t2[i])/(9*n-8)*(n-t1[j]-t2[j]-(i==j))/(9*n-9);
  }
  printf("%.10f\n", res);
  return 0;
}
