#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
const int N_ = (int)2e6 + 2;
long long n;
char a[N_], b[N_];
double res;
long long T;
int main() {
  scanf("%lld", &n);
  scanf("%s", a + 1);
  scanf("%s", b + 1);
  for (char cur = 'A'; cur <= 'Z'; cur++) {
    long long S = 0;
    for (int i = 1; i <= n; i++) {
      if (a[i] == cur) S += i;
      if (b[i] == cur) res += S * (n - i + 1);
    }
    S = 0;
    for (int i = 0; i <= n; i++) {
      if (a[i] == cur) res += S * (n - i + 1);
      if (b[i] == cur) S += i;
    }
  }
  for (int i = 1; i <= n; i++) T += (n - i + 1) * (n - i + 1);
  printf("%.9lf", res / T);
  return 0;
}
