#include <bits/stdc++.h>
using namespace std;
char a[200005], b[200005];
double c[200005], d[200005];
int main() {
  int n, j;
  double ans;
  while (scanf("%d", &n) != EOF) {
    ans = 0;
    scanf("%s%s", a + 1, b + 1);
    for (char k = 'A'; k <= 'Z'; k++) {
      c[0] = 0;
      d[n + 1] = 0;
      for (int i = 1; i <= n; i++) {
        if (a[i] == k)
          c[i] = c[i - 1] + i;
        else
          c[i] = c[i - 1];
      }
      for (int i = n; i >= 1; i--) {
        if (a[i] == k)
          d[i] = d[i + 1] + n - i + 1;
        else
          d[i] = d[i + 1];
      }
      for (int i = 1; i <= n; i++) {
        if (b[i] == k) ans += i * d[i] + (n - i + 1) * c[i - 1];
      }
    }
    printf("%lf\n", (double)ans * 6.0 / n / (n + 1) / (2 * n + 1));
  }
  return 0;
}
