#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500001;
const int MAXC = 501;
int n;
double sa[MAXC], sb[MAXC];
char a[MAXN], b[MAXN];
int main() {
  scanf("%d\n", &n);
  for (int i = 1; i <= n; ++i) scanf("%c", &a[i]);
  scanf("\n");
  for (int i = 1; i <= n; ++i) scanf("%c", &b[i]);
  scanf("\n");
  double res = 0;
  for (int i = 1; i <= n; ++i) {
    int x = a[i] - 'A' + 1;
    int y = b[i] - 'A' + 1;
    sa[x] += i;
    res += (sa[y] + sb[x]) * (n - i + 1);
    sb[y] += i;
  }
  printf("%.10f\n", res * 6 / n / (n + 1) / (n << 1 | 1));
  fclose(stdin);
  fclose(stdout);
  return 0;
}
