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