#include <bits/stdc++.h>
using namespace std;
int n;
char a[200010], b[200010];
double cna[256], cnb[256];
double res = 0;
int main() {
  scanf("%d\n", &n);
  gets(a);
  gets(b);
  for (int i = 0; i < n; ++i) {
    cna[a[i]] += i + 1;
    res += (n - i) * (cna[b[i]] + cnb[a[i]]);
    cnb[b[i]] += i + 1;
  }
  printf("%.20lf\n", 6 * res / n / (n + 1) / (2 * n + 1));
  return 0;
}
