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