#include <bits/stdc++.h>
int n;
char a[200001];
char b[200001];
int main() {
  scanf("%d", &n);
  scanf("%s %s", a, b);
  double sa[26] = {0};
  double sb[26] = {0};
  double p = 0;
  double q = 0;
  for (int i = 0; i < n; ++i) {
    p += sa[a[i] - 'A'] * (n - i);
    sa[b[i] - 'A'] += i + 1;
    q += (double)(i + 1) * (i + 1);
  }
  for (int i = n - 1; i >= 0; --i) {
    sb[b[i] - 'A'] += n - i;
    p += sb[a[i] - 'A'] * (i + 1);
  }
  printf("%.10lf\n", p / q);
  return 0;
}
