#include <bits/stdc++.h>
using namespace std;
char s1[200020], s2[200020];
int nn;
int main() {
  while (scanf("%d", &nn) == 1) {
    scanf("%s", s1 + 1);
    scanf("%s", s2 + 1);
    double n = nn;
    double sum = 0;
    for (int i = 1; i <= nn; ++i) sum += (double)i * (double)i;
    double ans = 0;
    for (int i = 1; i <= 26; ++i) {
      for (int j = 1; j <= n; ++j)
        if (s1[j] - 64 == i && s2[j] - 64 == i) ans += (n - j + 1) * j;
      double tmp = 0;
      for (int j = 1; j <= n; ++j) {
        if (s1[j] - 64 == i) ans += (n - j + 1) * tmp;
        if (s2[j] - 64 == i) tmp += j;
      }
      tmp = 0;
      for (int j = 1; j <= n; ++j) {
        if (s2[j] - 64 == i) ans += (n - j + 1) * tmp;
        if (s1[j] - 64 == i) tmp += j;
      }
    }
    printf("%.9f\n", ans / sum);
  }
  return 0;
}
