#include <bits/stdc++.h>
using namespace std;
int i, j, k, l, n, m, A[240000], B[240000], ta, tb, la, lb;
double sum, ans, fans;
char a[240000], b[240000];
int main() {
  scanf("%d", &n);
  scanf("%s%s", a + 1, b + 1);
  la = strlen(a + 1);
  lb = strlen(b + 1);
  for (i = 'A'; i <= 'Z'; ++i) {
    ta = tb = 0;
    for (j = 1; j <= la; ++j)
      if (a[j] == i) A[++ta] = j;
    for (j = 1; j <= lb; ++j)
      if (b[j] == i) B[++tb] = j;
    k = 1;
    sum = 0;
    for (j = 1; j <= ta; ++j) {
      while (k <= tb && B[k] < A[j]) {
        sum += B[k];
        k++;
      }
      ans += sum * (la - A[j] + 1);
    }
    k = tb;
    sum = 0;
    for (j = ta; j >= 1; --j) {
      while (k >= 1 && B[k] >= A[j]) {
        sum += lb - B[k] + 1;
        k--;
      }
      ans += sum * A[j];
    }
  }
  for (i = 1; i <= la && i <= lb; ++i)
    fans += (long long)(la - i + 1) * (lb - i + 1);
  printf("%.10lf\n", ans / fans);
}
