#include <bits/stdc++.h>
using namespace std;
char sa[200100], sb[200100];
long long aclb[26][200100], acrb[26][200100];
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    scanf(" %s %s", sa, sb);
    double res = 0;
    for (int c = 0; c < (26); c++) {
      for (int i = 0; i < (n); i++) {
        aclb[c][i] = (sb[i] == 'A' + c) ? (i + 1) : 0;
        if (i) aclb[c][i] += aclb[c][i - 1];
      }
      for (int i = n - 1; i >= 0; i--) {
        acrb[c][i] = (sb[i] == 'A' + c) ? (n - i) : 0;
        if (i < n - 1) acrb[c][i] += acrb[c][i + 1];
      }
    }
    for (int i = 0; i < (n); i++) {
      int c = sa[i] - 'A';
      if (i) res += aclb[c][i - 1] * (n - i);
      res += acrb[c][i] * (i + 1);
    }
    double den = 0;
    for (int i = 0; i < (n); i++) den += ((long long)(i + 1)) * (i + 1);
    printf("%.10lf\n", res / den);
  }
  return 0;
}
