#include <bits/stdc++.h>
using namespace std;
int n;
char a[200005], b[200005];
double suma[26][200005], sumb[26][200005], ma, cnt;
int main() {
  while (scanf("%d", &n) == 1) {
    ma = (double)n * ((double)n + 1.0) * (2.0 * (double)n + 1.0) / 6.0;
    scanf("%s", a);
    scanf("%s", b);
    int i, j;
    for (i = 0; i < 26; i++) {
      suma[i][0] = 0;
      sumb[i][0] = 0;
    }
    cnt = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < 26; j++) {
        suma[j][i + 1] = suma[j][i];
        sumb[j][i + 1] = sumb[j][i];
      }
      suma[a[i] - 'A'][i + 1] += i + 1;
      sumb[b[i] - 'A'][i + 1] += i + 1;
      cnt += (double)(n - i) * suma[b[i] - 'A'][i + 1];
      cnt += (double)(n - i) * sumb[a[i] - 'A'][i + 1];
      if (a[i] == b[i]) cnt -= (double)(i + 1.0) * (double)(n - i);
    }
    printf("%.12f\n", cnt / ma);
  }
  return 0;
}
