#include <bits/stdc++.h>
using namespace std;
double sumx[29], sumy[29];
double chu, ans;
char sz1[200006], sz2[200006];
int main() {
  int n, a, b, i;
  scanf("%d", &n);
  scanf("%s%s", sz1 + 1, sz2 + 1);
  for (i = 1; i <= n; i++) chu += i * i;
  for (i = 1; sz1[i]; i++) {
    a = sz1[i] - 'A';
    sumx[a] += i;
    b = sz2[i] - 'A';
    ans += (n - i + 1) * 1.0 * (sumx[b] + sumy[a]);
    sumy[b] += i;
  }
  printf("%0.8f\n", ((double)ans) / n / (n + 1) / ((n << 1) | 1) * 6);
}
